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

Allow format strings to be added #3

Closed
eddelbuettel opened this issue Sep 13, 2016 · 5 comments
Closed

Allow format strings to be added #3

eddelbuettel opened this issue Sep 13, 2016 · 5 comments
Labels

Comments

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Sep 13, 2016

Would allow to overcome the currently fixed set for odd formats like

  • %y for two-digit year, or even
  • %I %p for 12 hour time and am/pm,
  • any other format we don't currently have.
@adisarid
Copy link

@adisarid adisarid commented Sep 14, 2016

Great initiative for doing this package. Important feature in format strings context: some languages/localization (e.g., Hebrew) specify date in %d/%m/%Y instead of the worldwide standard (%m/%d/%Y). When inputting a vector such as:
anytime(c("14/09/2016", "01/09/2016"))
You get an NA for the first value and an opposite day-month for the second value, though you can probably deduce the meaning from some values (in the example the first value) and apply it on "localization-ambiguous" values (in the example, the second).
Probably a unique situation (according to localization), so should be applied using a parameter.

@eddelbuettel
Copy link
Owner Author

@eddelbuettel eddelbuettel commented Sep 14, 2016

Same with many European formats which do, say, %d.%m.%Y.

But this (famously) clashes with what North America does in its (braindead, but prevalent) %m/%d/%Y -- modulo the separators. There is no way to deal with the safely -- hence everybody's preference for ISO formats -- and strptime() et al have the same issue. I am not sure localization can help.

You can pre-load formats in the next version:

R> anytime:::addFormat("%d.%m.%Y") # Europe
R> anytime("10.11.2012")
[1] "2012-11-10 CST"
R> 

If you can work out how localization could help at the C++ level offered by Boost I'd be interested. Otherwise it is the "same old" issue also plagueing strptime() et al, and there is little I can do.

@eddelbuettel
Copy link
Owner Author

@eddelbuettel eddelbuettel commented Sep 14, 2016

Good news: Boost has %x for locale-dependent input, see the docs.

I plan to test that.

@eddelbuettel
Copy link
Owner Author

@eddelbuettel eddelbuettel commented Sep 15, 2016

Format strings can now be added.

@adisarid
Copy link

@adisarid adisarid commented Sep 15, 2016

Awesome, thanks!

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.