Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Implement support for ISO week dates #5
Probably not used very often, but having ISO week date formatting as a part of local-time would be nice to have. It makes sense for certain accounting/financial applications, and for retail/government according to Wikipedia. Personally, I am hacking on a side project where week manipulation is central.
Allegro's date-time API also has support for this and exposes some
The implementation is actually very simple thanks to some existing local-time functions and the following algorithm:
I started out by including three new values* to
Formatted-string tests for this feature are also included in this pull request.
The three values are mapped to the following keywords for
The first and last of these, which seem to be redundant, are due to the following:
One thing I was on the fence about was whether to expose the ISO week date decoding function in the API. I kept it private for now, as it would be rare to want to have the ISO week number, for example, in isolation from the ISO week year. Conversely, Allegro's API does have this flexibility. For now, it should be easy enough to use
There may also be room to better naming conventions than the ones I chose. :)
Fixed the above mentioned issue in b912578 by adding an additional
@dlowe-net, I was wondering if you could take a look at these changes and let me know what you think. Haven't re-squashed the commits so it's easier to see the progression. (The m-v-b makes the diff harder to parse.)