Source File
timestamp.go
Belonging Package
github.com/aws/aws-sdk-go/private/protocol
package protocol
import (
)
const (
RFC822TimeFormatName = "rfc822"
ISO8601TimeFormatName = "iso8601"
UnixTimeFormatName = "unixTimestamp"
)
RFC822TimeFormat = "Mon, 2 Jan 2006 15:04:05 GMT"
RFC822OutputTimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"
ISO8601TimeFormat = "2006-01-02T15:04:05.999999999Z"
ISO8601OutputTimeFormat = "2006-01-02T15:04:05.999999999Z"
)
func ( string) bool {
switch {
case RFC822TimeFormatName:
fallthrough
case ISO8601TimeFormatName:
fallthrough
case UnixTimeFormatName:
return true
default:
return false
}
}
func ( string, time.Time) string {
= .UTC().Truncate(time.Millisecond)
switch {
case RFC822TimeFormatName:
return .Format(RFC822OutputTimeFormat)
case ISO8601TimeFormatName:
return .Format(ISO8601OutputTimeFormat)
case UnixTimeFormatName:
:= .UnixNano() / int64(time.Millisecond)
return strconv.FormatFloat(float64()/1e3, 'f', -1, 64)
default:
panic("unknown timestamp format name, " + )
}
}
func (, string) (time.Time, error) {
switch {
case RFC822TimeFormatName:
return time.Parse(RFC822TimeFormat, )
case ISO8601TimeFormatName:
return time.Parse(ISO8601TimeFormat, )
case UnixTimeFormatName:
, := strconv.ParseFloat(, 64)
, := math.Modf()
= sdkmath.Round(*1e3) / 1e3 //Rounds 0.1229999 to 0.123
if != nil {
return time.Time{},
}
return time.Unix(int64(), int64(*(1e9))), nil
default:
panic("unknown timestamp format name, " + )
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |