Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DaysInMonth ¶
DaysInMonth returns the number of days in given month of given year.
Types ¶
type Period ¶
Period ISO-8601, independent of calendar (unless at moment it is applied to a timestamp with calendar reference).
func Between ¶
Between returns the period between two timestamps in a given location (hence DST may be noticeable). It first determines the date period between two timestamps (i.e. years, months, days). The start date is adjusted by the date period and then the time period between the timestamps are determined (i.e. hours, minutes, seconds). Finally the date and time parts are adjusted by flowing components, e.g. negative seconds are adjusted for positive minutes (and vice versa).
Example: 2016-02-28 and 2016-03-31 are +(1 month and 3 days) or -(1 month and 3 days) apart, note the inclusion of a leap day 2016 2017-03-26 00:00:00 and 2016-03-26 06:00:00 Europe/Amsterdam are +(5 hours) or -(5 hours) apart, note the DST transition 2017-03-26 00:00:00 and 2016-03-27 02:00:00 Europe/Amsterdam are +(1 day and 2 hours) or -(1 day and 2 hours) apart, note the DST insensitivity 2017-03-31 04:15:00 and 2016-03-31 05:10:00 are +(55 minutes) or -(55 minutes) apart, note the partial hour (similar in case of partial minute)
func FromDuration ¶
FromDuration returns period, floored to nearest second.
func FromString ¶
FromString returns period parsed from string.
func (Period) HasDatePart ¶
HasDatePart returns true iff any of years, months, weeks or days is not 0.
func (Period) HasTimePart ¶
HasTimePart returns true iff any of hours, minutes or seconds is not 0.