You are browsing as a guest. Sign up (or log in) to start making projects!

1h 31m 15s logged

strfmarstime - ~80% complete

After about 6 hrs total, the strfmarstime function is complete, using musl as a reference, except:

  • %E (era based format)
  • %k (hour as a decimal, but including padding 0s, probably this will be a quick fix
  • %O (modifier symbols?)
  • %P (lowercase version of “am” and “pm” - need to find a good way to run tolower on a const char*)
  • All week numbering formats, because there are different standards on when the week “starts” and “how many weeks we are into the year” (e.g. first 4 days of year, vs. whether week starts on Sunday vs. Monday)
  • %z, %Z (Timezones, not implemented yet)

This was quite the grind, having strftime docs open on one screen, musl’s implementation on another, and trying to go through each format while documenting and understanding how the formatting is being processed, one by one.

I also did some slight restructuring: the __mars_tm_to_secs function exists. It is basically what mkmarstime did. I would have it not subtract by epoch, but it was causing tests to fail. Technically the strftime docs say that %s, which uses it, calls the function anyways, so it may be pointless but whatever.

Oh, speaking of %s: That is seconds since the Unix epoch. Who knows how useful that will be when this calendar implementation starts at MSD 0 (like, 1873). Also, it’s martian seconds instead of Earth seconds.

Fun shoutout to “%%”, “%t”, and “%n”, which required nothing, just setting the length of the item to “1” and returning the actual formatting character. Lol.

Welp, now it’s time to test and drill this function into oblivion.

0
3

Comments 0

No comments yet. Be the first!