miller/test/cases/dsl-gmt-date-time-functions
John Kerl 72ffcb3414
Support %a %A %e %h %c %x %X in strptime (#1518) (#2179)
Miller's strftime delegates to the full-featured lestrrat-go/strftime
library, but strptime uses an in-tree fork of a small subset-only
package, so strftime output couldn't always be parsed back by
strptime with the same format string. This adds the format codes
needed to round-trip common formats like "%a %b %e %T %Y":

* %a / %A (weekday name) and %h (alias of %b): straightforward
  formatMap entries, same pattern as the existing %b/%B.
* %e (space-padded day of month): needed dedicated width-detection
  logic, since %e's own optional leading pad space is otherwise
  indistinguishable from a literal separator space when the code
  searches for the next literal text to bound a field -- this was
  the root cause of the round-trip failure in the linked issue.
* %c, %x, %X: shorthand aliases (expanding to %a %b %e %H:%M:%S %Y,
  %m/%d/%y, and %H:%M:%S respectively), same mechanism already used
  for %T/%D/%F/%R/%r.

Also documents the %D/%F/%r/%R/%T shorthands in the strptime table
in reference-dsl-time.md.in, which were already supported but
missing from the docs -- this was the exact confusion reported in
the discussion linked from #1518.

Round-trip tests added in pkg/bifs/datetime_test.go assert
strptime(strftime(t, fmt), fmt) == t across the newly-supported
formats, plus table-driven cases in
pkg/pbnjay-strptime/strptime_test.go covering %e's edge cases
(padded/unpadded single digit, double digit, adjacent to another
code with no separator, at end of string).

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-08 16:42:03 -04:00
..
0001 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0002 Fatal-on-data-error mlr -x option (#1373) 2023-08-30 19:39:22 -04:00
0003 Fatal-on-data-error mlr -x option (#1373) 2023-08-30 19:39:22 -04:00
0004 Fatal-on-data-error mlr -x option (#1373) 2023-08-30 19:39:22 -04:00
0005 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0005n Add DSL functions for integer nanoseconds since the epoch (#1326) 2023-06-24 17:05:15 -04:00
0006 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0007 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0008 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0009 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0010 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0011 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0011n Add DSL functions for integer nanoseconds since the epoch (#1326) 2023-06-24 17:05:15 -04:00
0012 Standardize Go-package structure (#746) 2021-11-11 14:15:13 -05:00
0013 Standardize Go-package structure (#746) 2021-11-11 14:15:13 -05:00
0014 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0015 Standardize Go-package structure (#746) 2021-11-11 14:15:13 -05:00
0016 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0017 Standardize Go-package structure (#746) 2021-11-11 14:15:13 -05:00
0018 Standardize Go-package structure (#746) 2021-11-11 14:15:13 -05:00
0019 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0019n Add DSL functions for integer nanoseconds since the epoch (#1326) 2023-06-24 17:05:15 -04:00
0020 Support %a %A %e %h %c %x %X in strptime (#1518) (#2179) 2026-07-08 16:42:03 -04:00
0020n Add DSL functions for integer nanoseconds since the epoch (#1326) 2023-06-24 17:05:15 -04:00
0021 Let dhms2sec accept input like "8h" (#983) 2022-03-14 23:47:50 -04:00