Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blastula::add_readable_time() converts all times to the 12 hour format, even if I change the locale #308

Open
alsmnn opened this issue Jul 12, 2023 · 0 comments

Comments

@alsmnn
Copy link

alsmnn commented Jul 12, 2023

Because of this formatting option time will always be reduced to the 12 hour format.
The typical 24 hour format can't be accomplished with this.

gsub(" |^0", "", format(time, "%I:%M")),

Even changing locale does not work:

withr::with_locale(c("LC_TIME" = "de_DE.UTF-8"), blastula::add_readable_time())
[1] "Mittwoch, Juli 12, 2023 at 5:26  (CEST)"

In this case the result should have been :
[1] "Mittwoch, Juli 12, 2023 at 17:26 (CEST)"

which could have been achieved by using %H in the format call: gsub(" |^0", "", format(time, "%H:%M")),
But because of the next line this does not work very well.

toupper(format(time, " %p"))

You will get an extra space, because 24 hour based formats don't have the option %p.
As you can see, there are two spaces between 5:26 and (CEST) (v0.3.2 currently installed
and in v0.3.3 it would be 05:26 (CEST))

> withr::with_locale(c("LC_TIME" = "en_US.UTF-8"), blastula::add_readable_time())
[1] "Wednesday, July 12, 2023 at 5:26 PM (CEST)"

In the second case PM is added, because of the locale, which is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant