strfmarstime testing - week numbers
Nothing crazy to report for the current testsuite and implementation verification I’ve been doing. Basically same thing as I did before I took a break for strpmarstime.
For some formats, it will literally print anything (if it’s invalid), which appears to be normal in Glibc, so it’s normal to me.
Some locale work too on AM/PM formatting and time formatting - some do “AM”, some do “am”, Spain does “a.m.”.
The big thing is:
Week Numbers
Okay, so there are three different definitions of week numbers:
-
%U: The first day of week 1 is on Sunday. Range 00 (because sometimes in January we don’t get to Sunday for a few days), up until 53 (sometimes we actually get 53 weeks due to day placement.)
-
%V: ISO 8601, which has week 1 as the first week with at least 4 days in the new year. Range 01 to 53. (Week 0 would be represented by 52, in my testing)
-
%W: The first day of week 1 is on Monday.
But, here is the key thing about the Darian calendar: Each month resets the week. This is actually one of the things about the Gregorian Calendar some people don’t like-how the # of the day is on inconsistent weekdays.
The Darian Calendar has a neat 28 days for each month, so with 7 days a week, this isn’t a problem. And since each week is guaranteed to have four days, we can just take the number of days and divide by 7. For %W, shift by 1, because Monday (Lunae) is not the first day of the week.
However.. every 6th month is the end of a season, and it has 27 days. So we need to, in our calculations, which must go based off the nth day of the year, make sure we reset, otherwise we will lose our day alignment (because again, the week resets). So we need to realign every 167 days, and also check how many seasons passed and use that to get the amount of prior weeks we are skipping when we have modulated.
As for the leap day: It divides perfectly by 7 and 167, so it gets its own if statement case (otherwise it would read “97”).
Experience
I knew this would be weird to figure out, and challenging, but I actually had a lot of fun doing it. It kept my brain working, I stayed energetic, and I managed to have fun, which is the most important thing!
So after my long Pomodoro break, I’ll verify %W (since %U and %V are thee same), and then %w, %x, %X, %y and %Y and that will be it, since for an initial ship I don’t plan to do timezones.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.