mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-11 23:46:39 +08:00

test(time) expose time format var License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
18 lines
310 B
Go
18 lines
310 B
Go
package util
|
|
|
|
import "time"
|
|
|
|
var TimeFormatIpfs = time.RFC3339Nano
|
|
|
|
func ParseRFC3339(s string) (time.Time, error) {
|
|
t, err := time.Parse(TimeFormatIpfs, s)
|
|
if err != nil {
|
|
return time.Time{}, err
|
|
}
|
|
return t.UTC(), nil
|
|
}
|
|
|
|
func FormatRFC3339(t time.Time) string {
|
|
return t.UTC().Format(TimeFormatIpfs)
|
|
}
|