Documentation ¶
Overview ¶
Package iso8601 provides support for parsing and formatting ISO 8601 constructs. Formatting methods accept a time.Time instance and return the appropriate ISO 8601 string. Parsing methods accept an ISO 8601 string and return a time.Time instance.
Index ¶
- Constants
- Variables
- func FormatDateTime(t time.Time, layout string) string
- func FormatDuration(dur time.Duration) string
- func FormatOrdinalDate(date time.Time) string
- func FormatWeek(date time.Time, shortForm bool) string
- func ISOYearWeeks(gregYear int) int
- func ParseDateTime(isoTime, layout string) (time.Time, error)
- func ParseDuration(isoDuration string) (time.Duration, error)
- func ParseOrdinalDate(isoOrdinalDate string) (time.Time, error)
- func ParseWeek(isoWeek string) (time.Time, error)
- func Weekday(year, month, day int) int
Constants ¶
const ( ISOYear = "2006" ISOYearMonth = "2006-01" ISOFullDate = "2006-01-02" ISOHoursMinutes = "15:04" ISOHoursMinutesSeconds = "15:04:05" ISOFullTime = "15:04:05.000" ISOTzZulu = "Z" ISOTzOffsetHours = "-07" ISOTzOffsetHoursMinutes = "-07:00" MinWeek = 1 MinYear = 1 MaxYear = 9999 )
These are layout constants that supplement the layout constants provided by time.Time. Note: golang's time.RFC3339 constant represents a layout string containing ISO Date, full ISO time (minus milliseconds) and time zone.
Variables ¶
var ErrWeekRange = fmt.Errorf("week is out of range (valid range: %d–number of iso weeks in the given year inclusive)", MinWeek)
ErrWeekRange is returned when a week is not within our permitted range.
var ErrYearRange = fmt.Errorf("year is out of range (valid range: %d–%d inclusive)", MinYear, MaxYear)
ErrYearRange is returned when a week is not within our permitted range.
Functions ¶
func FormatDateTime ¶
FormatDateTime returns an ISO 8601 date.
func FormatDuration ¶
FormatDuration returns an ISO 8601 duration string.
func FormatOrdinalDate ¶
FormatOrdinalDate returns an ISO 8601 ordinal date string. In this context, Ordinal date represents the nth day of the year.
func FormatWeek ¶
FormatWeek returns an ISO 8601 week string.
func ISOYearWeeks ¶
ISOYearWeeks returns the number of ISO weeks contained in a given Gregorian calendar year.
func ParseDateTime ¶
ParseDateTime parses an ISO 8601 string representing a date or time or date+time, and returns the resultant golang time.Time insance.
func ParseDuration ¶
ParseDuration parses an ISO 8601 string representing a duration, and returns the resultant golang time.Duration instance.
func ParseOrdinalDate ¶
ParseOrdinalDate parses an ISO 8601 string representing a ordinal date, and returns the resultant golang time.Time insance.
func ParseWeek ¶
ParseWeek parses an ISO 8601 string representing an ISO week, and returns the resultant golang time.Time instance. Note: if the ISO week is of the short form (doesn't include day of week), this function will return a time.Time instance with day of week of Monday.
func Weekday ¶
Weekday returns day of week with Monday=0...Sunday=6. Utilizes Zeller's Congruence. see: https://en.wikipedia.org/wiki/Zeller%27s_congruence
Types ¶
This section is empty.