time.go 310 Bytes
Newer Older
Jeromy's avatar
Jeromy committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
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)
}