OpenRefine / openrefine.org

Source website for openrefine.org
https://openrefine.org
Other
133 stars 119 forks source link

Documentation for toString() date format codes is incorrect #376

Open pumalife opened 3 days ago

pumalife commented 3 days ago

value: 2024-01-17T00:00:00Z value.toString('u') should return the day number for the current week ( ie 1-7) as indicated in https://openrefine.org/docs/manual/grelfunctions#date-functions

but its returning 2024 ive tried this with a text value and converted it to date, manually specifying the format date text value. ie value.toDate('y/m/d').toString('u') and it still outputs 2024

tfmorris commented 2 days ago

The documentation is incorrect. You can find the correct field letters here: https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html

The reference to https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html is outdated, but we generally try to preserve compatibility, so I'm not sure what other incompatibilities are lurking here.

tfmorris commented 1 day ago

I went through the two pages and I think these are the differences

Old (SimpleDateFormat) New (DateTimeFormatter) Meaning Comment
y u Year y = year of era, which will be the same in most cases
F [none]? Day of week in month no equivalent? F is documented as "week of month" for new
u e Day of week e is actually "localized day of week"