Skip to content

Conversation

@bvisness
Copy link

@bvisness bvisness commented Dec 10, 2023

The implementation of os.date didn't support many flags that I was used to from other systems. This new implementation supports many more of the flags from the C standard for strftime, plus some utilities borrowed from other strftime implementations such as glibc and Ruby.

The overall changes are:

  • Added the following flags unchanged from the C spec: %n, %t, %j, %e, %D, %r, %R, %T, %G, %g, %V
  • %x was just wrong; it formatted a time as if it was a date. It has now been defined to be the same as %D.
  • Added:
    • %-m: trimmed month
    • %-d: trimmed day of month

I see that this flag-scanning code is also used by strGsubStr. Please do let me know if my changes are unacceptable because of that!

@LittleToonCat
Copy link

Would like to know when this will get merged. My Lua code uses os.date but %a is not formatted correctly in the current gopher-lua codebase and will always result in "mon" instead "Mon" or any other correct day for that matter. I was going to submit a fix for that bug myself, but then this PR came along and now I am just waiting for it to get merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants