Closed maraino closed 2 months ago
This PR improves the functions added in https://github.com/smallstep/crypto/pull/534 with some usability changes.
toTime 1719970524
time.Time
formatTime (now)
parseTime
mustParseTime
parseTime "2024-07-03T01:30:39Z"
parseTime "time.UnixDate" "Tue Jul 2 18:31:04 PDT 2024"
parseTime "time.UnixDate" "Tue Jul 2 18:31:04 PDT 2024" "America/Los_Angeles"
toTimeLayout
toTimeLayout "RFC3339"
2006-01-02T15:04:05Z07:00
toTimeLayout "time.UnixDate"
Mon Jan _2 15:04:05 MST 2006
Description
This PR improves the functions added in https://github.com/smallstep/crypto/pull/534 with some usability changes.
toTime 1719970524
returns atime.Time
in UTC from a time or a Unix epoch.formatTime (now)
: from a time or Unix epoch returns a time string using RFC3339 format UTC.parseTime
andmustParseTime
:parseTime
: returns the currenttime.Time
in UTC.parseTime "2024-07-03T01:30:39Z"
: parses the given time using RFC3339.parseTime "time.UnixDate" "Tue Jul 2 18:31:04 PDT 2024"
: parses a time using a given format.parseTime "time.UnixDate" "Tue Jul 2 18:31:04 PDT 2024" "America/Los_Angeles"
: parses a time with the given format and time zone.toTimeLayout
returns a layout format from the given name.toTimeLayout "RFC3339"
returns2006-01-02T15:04:05Z07:00
toTimeLayout "time.UnixDate"
returnsMon Jan _2 15:04:05 MST 2006