Documentation ¶
Index ¶
- Constants
- type Date
- type DateTime
- func (dt DateTime) AsTime() Time
- func (dt DateTime) DefaultDateFormat() string
- func (dt DateTime) DefaultTimeFormat() string
- func (dt DateTime) EncodeValues(key string, v *url.Values) error
- func (dt DateTime) EndOfDay() DateTime
- func (dt DateTime) LocalTimestamp() int64
- func (dt DateTime) MarshalJSON() ([]byte, error)
- func (dt DateTime) MinutesSinceDateMidnight(since DateTime) int
- func (dt DateTime) MinutesSinceMidnight() int
- func (dt DateTime) RoundDown(d time.Duration) DateTime
- func (dt DateTime) RoundUp(d time.Duration) DateTime
- func (dt DateTime) String() string
- func (dt DateTime) TruncateDate() DateTime
- func (dt *DateTime) UnmarshalJSON(input []byte) error
- func (dt DateTime) WithDate(year int, month time.Month, day int) DateTime
- type DateTimeProvider
- type Time
Constants ¶
const DefaultDateFormat = "2006-01-02"
const DefaultDateTimeFormat = "2006-01-02 15:04"
const DefaultTimeFormat = "15:04"
const FullDateTimeFormat = "2006-01-02 15:04:05"
const FullDateTimeFormatWithT = "2006-01-02T15:04:05"
const RussianDateFormat = "02-01-2006"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Date ¶
Date type represents a date with day precision. Date values can be created from YYYY-MM-DD strings and are serialized using the same layout. swaggen:type=string swaggen:format=date
func MustParseDate ¶
MustParseDate creates a Date object from a string in YYYY-MM-DD format and panics if the string is not properly formatted.
func ParseDate ¶
ParseDate creates a Date value from a string in YYYY-MM-DD format. It will return an error if the string is not properly formatted.
func (Date) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface and serializes Date value in YYYY-MM-DD format string.
func (*Date) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface and parses a string in YYYY-MM-DD format to Date value.
type DateTime ¶
DateTime type represents a time with date with minute precision. swaggen: type=string swaggen: format=date-time
func MustParseDateTime ¶
MustParseDateTime creates a DateTime object from a string in "YYYY-MM-DD HH:mm" format and panics if the string is not properly formatted.
func MustParseTime ¶
MustParseTime creates a DateTime object from a string in "HH:mm" format. It will return DateTime with date in "0000-01-01" format. It will panic if the string is not properly formatted.
func NewDateTime ¶
func ParseDateTime ¶
ParseDateTime creates a DateTime value from a string in "YYYY-MM-DD HH:mm" format. It will return an error if the string is not properly formatted.
func ParseTime ¶
ParseTime creates a DateTime value from a string in "HH:mm" format. It will return DateTime with date in "0000-01-01" format. It will return an error if the string is not properly formatted.
func (DateTime) DefaultDateFormat ¶
DefaultDateFormat returns a string representation of a DateTime in "YYYY-MM-DD" format.
func (DateTime) DefaultTimeFormat ¶
DefaultTimeFormat returns a string representation of a DateTime in "HH:mm" format.
func (DateTime) LocalTimestamp ¶
LocalTimestamp returns unix timestamp + time zone offset.
func (DateTime) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface and serializes DateTime value in "YYYY-MM-DD HH:mm" format string.
func (DateTime) MinutesSinceDateMidnight ¶
func (DateTime) MinutesSinceMidnight ¶
func (DateTime) String ¶
String returns a string representation of a DateTime in "YYYY-MM-DD HH:mm" format.
func (DateTime) TruncateDate ¶
func (*DateTime) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface and parses a string in "YYYY-MM-DD HH:MM" format to DateTime value.
type DateTimeProvider ¶
type DateTimeProvider struct{}
func (DateTimeProvider) Now ¶
func (p DateTimeProvider) Now() DateTime
type Time ¶
Time type represents a time with seconds precision. Time values can be created from HH:MM:SS strings and are serialized using the same layout. swaggen:type=string
func MustParseAsTime ¶
MustParseAsTime creates a Time object from a string in HH:MM:SS format and panics if the string is not properly formatted.
func ParseAsTime ¶
ParseAsTime creates a Time value from a string in HH:MM:SS format. It will return an error if the string is not properly formatted.
func (Time) DefaultTimeFormat ¶
DefaultTimeFormat returns a string representation of a Time in HH:MM format.
func (Time) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface and serializes Time value in HH:MM:SS format string.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface and parses a string in HH:MM:SS format to Time value.