Added unix strftime support to gval functions
This commit is contained in:
@@ -190,10 +190,15 @@ func prepMod(base interface{}, mod interface{}) (*time.Time, int, error) {
|
||||
// https://github.com/lestrrat-go/strftime#supported-conversion-specifications
|
||||
func strfTime(base interface{}, f string) (string, error) {
|
||||
t, _, err := prepMod(base, 0)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
o, _ := strftime.Format(f, *t, strftime.WithMilliseconds('b'))
|
||||
|
||||
o, _ := strftime.Format(f, *t,
|
||||
strftime.WithMilliseconds('b'),
|
||||
strftime.WithUnixSeconds('L'))
|
||||
|
||||
return o, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -134,3 +134,10 @@ func Example_subErrorCheck() {
|
||||
// output:
|
||||
// error: can not evaluate sub(ghd, hgp): expecting 2nd input to be less than 1st input
|
||||
}
|
||||
|
||||
func Example_unix() {
|
||||
eval(`strftime(ghd, "%L")`, exampleTimeParams)
|
||||
|
||||
// output:
|
||||
// 728650800
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user