- 0.122.0 (latest)
- 0.121.6
- 0.120.1
- 0.119.0
- 0.118.3
- 0.117.0
- 0.116.0
- 0.115.1
- 0.114.0
- 0.113.0
- 0.112.2
- 0.111.0
- 0.110.10
- 0.109.0
- 0.108.0
- 0.107.0
- 0.106.0
- 0.105.0
- 0.104.0
- 0.103.0
- 0.102.1
- 0.101.1
- 0.100.2
- 0.99.0
- 0.98.0
- 0.97.0
- 0.96.0
- 0.95.0
- 0.94.1
- 0.93.3
- 0.92.3
- 0.91.1
- 0.90.0
- 0.89.0
- 0.88.0
- 0.87.0
- 0.86.0
- 0.85.0
- 0.84.0
- 0.83.0
- 0.82.0
- 0.81.0
- 0.80.0
- 0.79.0
- 0.78.0
- 0.77.0
- 0.76.0
- 0.75.0
Package civil implements types for civil time, a time-zone-independent representation of time that follows the rules of the proleptic Gregorian calendar with exactly 24-hour days, 60-minute hours, and 60-second minutes.
Because they lack location information, these types do not represent unique moments or intervals of time. Use time.Time for that purpose.
Date
type Date struct {
Year int // Year (e.g., 2014).
Month time.Month // Month of the year (January = 1, ...).
Day int // Day of the month, starting at 1.
}
A Date represents a date (year, month, day).
This type does not include location information, and therefore does not describe a unique 24-hour timespan.
func DateOf
DateOf returns the Date in which a time occurs in that time's location.
func ParseDate
ParseDate parses a string in RFC3339 full-date format and returns the date value it represents.
func (Date) AddDays
AddDays returns the date that is n days in the future. n can also be negative to go into the past.
func (Date) After
After reports whether d occurs after d2.
func (Date) Before
Before reports whether d occurs before d2.
func (Date) DaysSince
DaysSince returns the signed number of days between the date and s, not including the end day. This is the inverse operation to AddDays.
func (Date) In
In returns the time corresponding to time 00:00:00 of the date in the location.
In is always consistent with time.Date, even when time.Date returns a time on a different day. For example, if loc is America/Indiana/Vincennes, then both time.Date(1955, time.May, 1, 0, 0, 0, 0, loc) and civil.Date{Year: 1955, Month: time.May, Day: 1}.In(loc) return 23:00:00 on April 30, 1955.
In panics if loc is nil.
func (Date) IsValid
IsValid reports whether the date is valid.
func (Date) IsZero
IsZero reports whether date fields are set to their default value.
func (Date) MarshalText
MarshalText implements the encoding.TextMarshaler interface. The output is the result of d.String().
func (Date) String
String returns the date in RFC3339 full-date format.
func (*Date) UnmarshalText
UnmarshalText implements the encoding.TextUnmarshaler interface. The date is expected to be a string in a format accepted by ParseDate.
DateTime
A DateTime represents a date and time.
This type does not include location information, and therefore does not describe a unique moment in time.
func DateTimeOf
DateTimeOf returns the DateTime in which a time occurs in that time's location.
func ParseDateTime
ParseDateTime parses a string and returns the DateTime it represents. ParseDateTime accepts a variant of the RFC3339 date-time format that omits the time offset but includes an optional fractional time, as described in ParseTime. Informally, the accepted format is YYYY-MM-DDTHH:MM:SS[.FFFFFFFFF] where the 'T' may be a lower-case 't'.