Cursed knowledge of the day: how to use nl_langinfo() to find the start day of the week in your locale.
github.com/util-linux/util-lin…
util-linux/misc-utils/cal.c at 49a7b29e9f727dde4e8601f4d2ca2fbc4846258f · util-linux/util-linux
Contribute to util-linux/util-linux development by creating an account on GitHub.GitHub


penguin42
in reply to Federico Mena Quintero • • •Federico Mena Quintero
in reply to penguin42 • • •@penguin42 I don't fully understand it. GTK3 obviates part of it: gitlab.gnome.org/GNOME/gtk/-/b…
I.e. nl_langinfo() gives you back a date from 1997, which is a Sunday or a Monday, and you need to figure out which it is (by hardcoding it like GTK3, or by doing Gregorian calculations like cal(1)). Then you add the other day offset reported by nl_langinfo() and use that.
I have NO CLUE why it requires using a crazy union like that.
gtk/gtkcalendar.c · faa078713e7c73919d5649c7ccd8797f637bcee5 · GNOME / gtk · GitLab
GitLabJames Henstridge
in reply to Federico Mena Quintero • • •@penguin42 This gives some hints about the union use: sourceware.org/bugzilla/show_b…
It's using a union because nl_langinfo() is using a union rather than casting integer values to (char *). So that means the other 4 bytes of the pointer may be garbage, and the integer value might not be in the least significant bytes of the pointer.
It probably seemed fairly convenient back when the types were the same size.
11828 – Please provide supported equivalents of _NL_*
sourceware.orgFederico Mena Quintero
in reply to James Henstridge • • •