gramps-project / gramps-web-api

A RESTful web API for Gramps
GNU Affero General Public License v3.0
77 stars 40 forks source link

Add date format query parameter #337

Open DavidMStraub opened 1 year ago

DavidMStraub commented 1 year ago

See https://github.com/gramps-project/Gramps.js/pull/178 for rationale.

Date formats are identified by integers, where 0 (current default) always refers to YYYY-MM-DD ISO format and higher numbers depend on the locale. The number of formats differs per locale.

We need the date_format argument everywhere where locale.date_displayer appears in the code.

hartenthaler commented 10 months ago

Maybe this is the reason why I see in the German user interface dates as "yyyy-mm-dd" instead of "dd.mm.yyyy".

DavidMStraub commented 10 months ago

Yes, that's correct. I'm personally a big fan of the ISO format which is why it hasn't bothered me so far, but this is feature definitely worth adding. And it's also not difficult, so let me add the good first issue label.

emyoulation commented 10 months ago

Pardon my opinion but using an integer pointer to a list that is customizable is a fragile approach.

We've already send that has shown problems in the portability of report books. They point to lists of reports, which point a lists of custom filters. And the custom filters point to lists of Rules that can have addon plugin rules. All those lists are user adjustable, stored locally but external to the database, and not included in or backups.

So the lists of date formats, Place formats and Name formats are very fragile. They should have a redundancy string representation.

DavidMStraub commented 10 months ago

Hi,

why customizable? There is a fixed lis of formats per language, like here, isn't it?

By the way, one additional issue is that Gramps Web doesn't leverage the Gramps date formatter everywhere - sometimes it displays the date based on raw data, which is possible for YYYY-MM-DD, but not for more complicated formats. So after implementing this, some of the dates will still be ISO.

emyoulation commented 7 months ago

There is a preference for adding a modifier for the Date format, a calendar selector (which can be expanded with add-ons). And a common issue having to do with ambiguity of Dates imported from systems that use non-standard format. (In the US and some Canada the MM/DD/YY or M/M/YYYY is common. But the rest of the world uses DD/MM/YY. Japan uses YY/MM/DD. The separators may be slashes, dashes or periods.)

DavidMStraub commented 7 months ago

We are just using built-in Gramps formatting for existing dates, so calendars are already properly handled. It's just about customizing the display of the date part, which is currently not modifiable from the default YYYY-MM-DD.