strptime support for non zero-padded values? #1197
|
Hi, I'm running into an issue when attempting to parse non zero-padded values with echo d='1/6/2022' | mlr --opprint put '$ts = strptime($d,"%m/%d/%Y")'Output d ts
1/6/2022 (error)Support for non zero-padded values with the standard If non zero-padded values are not supported in Miller's Thanks. |
Replies: 3 comments
|
Hi @archetyped I have no satisfactory answer for you. But I add a note for @johnkerl : using Miller 5, it works. |
|
Thanks @aborruso and @johnkerl for looking into this. In the meantime, I'm currently dealing with non zero-padded date values with a simple regex replacement: gsub($d, "\b(\d)\b", "0\1")So the steps for parsing the date looks like: echo d='1/6/2022' | \
mlr --opprint --barred put \
'$d_fix = gsub($d, "\b(\d)\b", "0\1");
$ts = strptime($d_fix,"%m/%d/%Y");
$d_fmt = strftime($ts, "%F")'Output More fragile than actual parsing, but it works in the interim. I'd love to hear of any cleaner workarounds that others can think of. |
Hi @archetyped I have no satisfactory answer for you. But I add a note for @johnkerl : using Miller 5, it works.