itchyny / gojq

Pure Go implementation of jq
MIT License
3.3k stars 119 forks source link

Could `mktime` have sub-second resolution? #171

Closed amesgen closed 2 years ago

amesgen commented 2 years ago

Consider

 $ echo '"2022-04-12T14:34:13.55Z"' | gojq 'strptime("%Y-%m-%dT%H:%M:%S.%fZ") | mktime'
1649774053

I think it would be useful if this could return 1649774053.55 (or if there was an alternative to mktime which did). It can be emulated with

 $ echo '"2022-04-12T14:34:13.55Z"' | gojq 'strptime("%Y-%m-%dT%H:%M:%S.%fZ") | (mktime + .[5] - (.[5] | floor))'
1649774053.55

which is a bit convoluted.

itchyny commented 2 years ago

This is already supported in the HEAD version.

amesgen commented 2 years ago

Excellent, thanks, closing then!