v0.0.93
This commit is contained in:
@@ -3,24 +3,27 @@ package rfctime
|
||||
import "time"
|
||||
|
||||
type RFCTime interface {
|
||||
AnyTime
|
||||
|
||||
Time() time.Time
|
||||
Serialize() string
|
||||
|
||||
UnmarshalJSON(bytes []byte) error
|
||||
After(u AnyTime) bool
|
||||
Before(u AnyTime) bool
|
||||
Equal(u AnyTime) bool
|
||||
|
||||
Sub(u AnyTime) time.Duration
|
||||
}
|
||||
|
||||
type AnyTime interface {
|
||||
MarshalJSON() ([]byte, error)
|
||||
|
||||
MarshalBinary() ([]byte, error)
|
||||
UnmarshalBinary(data []byte) error
|
||||
|
||||
GobEncode() ([]byte, error)
|
||||
GobDecode(data []byte) error
|
||||
|
||||
MarshalText() ([]byte, error)
|
||||
UnmarshalText(data []byte) error
|
||||
|
||||
After(u RFCTime) bool
|
||||
Before(u RFCTime) bool
|
||||
Equal(u RFCTime) bool
|
||||
IsZero() bool
|
||||
Date() (year int, month time.Month, day int)
|
||||
Year() int
|
||||
@@ -34,7 +37,6 @@ type RFCTime interface {
|
||||
Second() int
|
||||
Nanosecond() int
|
||||
YearDay() int
|
||||
Sub(u RFCTime) time.Duration
|
||||
Unix() int64
|
||||
UnixMilli() int64
|
||||
UnixMicro() int64
|
||||
@@ -42,6 +44,8 @@ type RFCTime interface {
|
||||
Format(layout string) string
|
||||
GoString() string
|
||||
String() string
|
||||
|
||||
Location() *time.Location
|
||||
}
|
||||
|
||||
type RFCDuration interface {
|
||||
@@ -60,9 +64,9 @@ type RFCDuration interface {
|
||||
MarshalText() ([]byte, error)
|
||||
UnmarshalText(data []byte) error
|
||||
|
||||
After(u RFCTime) bool
|
||||
Before(u RFCTime) bool
|
||||
Equal(u RFCTime) bool
|
||||
After(u AnyTime) bool
|
||||
Before(u AnyTime) bool
|
||||
Equal(u AnyTime) bool
|
||||
IsZero() bool
|
||||
Date() (year int, month time.Month, day int)
|
||||
Year() int
|
||||
@@ -76,7 +80,7 @@ type RFCDuration interface {
|
||||
Second() int
|
||||
Nanosecond() int
|
||||
YearDay() int
|
||||
Sub(u RFCTime) time.Duration
|
||||
Sub(u AnyTime) time.Duration
|
||||
Unix() int64
|
||||
UnixMilli() int64
|
||||
UnixMicro() int64
|
||||
@@ -85,3 +89,13 @@ type RFCDuration interface {
|
||||
GoString() string
|
||||
String() string
|
||||
}
|
||||
|
||||
func tt(v AnyTime) time.Time {
|
||||
if r, ok := v.(time.Time); ok {
|
||||
return r
|
||||
}
|
||||
if r, ok := v.(RFCTime); ok {
|
||||
return r.Time()
|
||||
}
|
||||
return time.Unix(0, v.UnixNano()).In(v.Location())
|
||||
}
|
||||
|
Reference in New Issue
Block a user