lubridate icon indicating copy to clipboard operation
lubridate copied to clipboard

Ordinal date when formatting

Open MyKo101 opened this issue 3 years ago • 1 comments

Would it be possible to include ordinal dates when creating a stamp() function?

For example, if I run:

f <- stamp("1st January 2021")
f(dmy("02/02/2021"))

I get as an output:

"02st February 2021"

I would expect the output to be

"2nd February 2021"

There are two things to note here, the ordinal value has been replaced correctly ("nd" instead of "st") and the leading 0 for the date has been dropped.

As far as I understand, there is not an R format shortcut for these ordinals. I have a workaround where I gsub() a different value in, but having this built into lubridate would be useful.

MyKo101 avatar Feb 04 '21 21:02 MyKo101

Thanks for the proposal. Making this work for different languages is not feasible I am afraid. Implementing just for english, while not very difficult, would create a special treatment. Overal I think it's not worth it.

I will keep this as a reminder for the parser rewrite. Adding the "ordinal day" format as you suggest might be worth it.

vspinu avatar Feb 24 '21 12:02 vspinu