datetime

package
v0.0.0-...-fa13bed Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Code generated by go run glr_generate parse_yacc.y parse_yacc.states.txt. DO NOT EDIT.

Code generated by goyacc -l -o parse_yacc.go -v parse_yacc.states.txt parse_yacc.y. DO NOT EDIT.

Index

Constants

View Source
const A = 57347
View Source
const ADD = 57348
View Source
const AM = 57349
View Source
const AMP = 57350
View Source
const AND = 57351
View Source
const AT = 57352
View Source
const BEGINNING = 57353
View Source
const CALENDAR = 57354
View Source
const COLON = 57355
View Source
const COMMA = 57356
View Source
const DATE = 57357
View Source
const DATES = 57358
View Source
const DEC = 57359
View Source
const FROM = 57360
View Source
const GOOGLE = 57361
View Source
const ICS = 57362
View Source
const IDENT = 57389
View Source
const ILLEGAL = 57346
View Source
const IN = 57363
View Source
const INT = 57390
View Source
const LPAREN = 57364
View Source
const MONTH_NAME = 57391
View Source
const NEXT = 57365
View Source
const OF = 57366
View Source
const ON = 57367
View Source
const ORD_IND = 57368
View Source
const P = 57370
View Source
const PART = 57369
View Source
const PERIOD = 57372
View Source
const PM = 57371
View Source
const QUO = 57373
View Source
const RELATIVE_DAY = 57395
View Source
const RPAREN = 57374
View Source
const SAVE = 57375
View Source
const SEMICOLON = 57376
View Source
const SUB = 57377
View Source
const T = 57379
View Source
const TH = 57380
View Source
const THE = 57381
View Source
const THIS = 57382
View Source
const THROUGH = 57378
View Source
const TILL = 57383
View Source
const TIME = 57384
View Source
const TIME_NAME = 57392
View Source
const TIME_ZONE = 57393
View Source
const TIME_ZONE_ABBREV = 57394
View Source
const TO = 57385
View Source
const UNTIL = 57386
View Source
const WEEKDAY_NAME = 57396
View Source
const WEEKDAY_SHORT_NAME = 57397
View Source
const WHEN = 57387
View Source
const YEAR = 57398
View Source
const Z = 57388

Variables

View Source
var DateModeNorthAmerican = "na"

North American tends to parse dates as month-day-year.

View Source
var DateModeNorthAmericanCountryCodes = map[string]bool{"CA": true, "US": true}
View Source
var DateModeRest = "rest"
View Source
var DateModeUnknown = ""
View Source
var DoDebug = false
View Source
var PreferredLocationNamesByAbbrev = map[string]string{
	"BST":  "Europe/London",
	"ET":   "America/New_York",
	"EDT":  "America/New_York",
	"EST":  "America/New_York",
	"CET":  "Europe/Paris",
	"CEST": "Europe/Paris",
	"CT":   "America/Chicago",
	"CDT":  "America/Chicago",
	"CST":  "America/Chicago",
	"GMT":  "Europe/London",
	"MT":   "America/Denver",
	"MDT":  "America/Denver",
	"MST":  "America/Denver",
	"PT":   "America/Los_Angeles",
	"PDT":  "America/Los_Angeles",
	"PST":  "America/Los_Angeles",
}

Functions

func CleanTextLine

func CleanTextLine(s string) string

func DateMode

func DateMode(tz *TimeZone) string

func HasStartMonthAndDay

func HasStartMonthAndDay(rngs *DateTimeRanges) bool

func NewDatetimeLexer

func NewDatetimeLexer(input string) *datetimeLexer

func SetDebug

func SetDebug(enabled bool)

SetDebug toggles debug logging

Types

type Date

type Date struct {
	Year  int        // Year (e.g., 2014), starting at 1.
	Month time.Month // Month of the year, starting at 1 for January.
	Day   int        // Day of the month, starting at 1.
	// contains filtered or unexported fields
}

A Date represents a date (year, month, day, weekday).

This type does not include location information, and therefore does not describe a unique 24-hour timespan.

When a field is unspecified, it holds 0.

func NewDateFromRaw

func NewDateFromRaw(d *Date, tz *TimeZone) *Date

func NewRawDateFromAmbiguous

func NewRawDateFromAmbiguous(weekdayAny any, first string, last string, yearAny any) *Date

func NewRawDateFromDMY

func NewRawDateFromDMY(dayAny any, monthAny any, yearAny any) *Date

func NewRawDateFromDsMYs

func NewRawDateFromDsMYs(daysAny []string, monthAny any, yearAny any) []*Date

func NewRawDateFromMDY

func NewRawDateFromMDY(monthAny any, dayAny any, yearAny any) *Date

func NewRawDateFromMDsYs

func NewRawDateFromMDsYs(monthAny any, daysAny []string, yearAny any) []*Date

func NewRawDateFromRelative

func NewRawDateFromRelative(relativeName string) *Date

func NewRawDateFromWDMY

func NewRawDateFromWDMY(weekdayAny any, dayAny any, monthAny any, yearAny any) *Date

func NewRawDateFromWMDY

func NewRawDateFromWMDY(weekdayAny any, monthAny any, dayAny any, yearAny any) *Date

func NewRawDateFromYMD

func NewRawDateFromYMD(yearAny any, monthAny any, dayAny any) *Date

func (*Date) String

func (d *Date) String() string

String returns the date in RFC3339 full-date format.

func (*Date) ToTime

func (d *Date) ToTime() *time.Time

type DateTime

type DateTime struct {
	Date     *Date
	Time     *Time
	TimeZone *TimeZone
}

A DateTime represents a date and time with a time zone.

This type DOES include location information.

func NewDateTime

func NewDateTime(d *Date, t *Time, tz *TimeZone) *DateTime

func NewDateTimeForNow

func NewDateTimeForNow() *DateTime

func NewDateTimeForRFC1123Z

func NewDateTimeForRFC1123Z(tStr string) *DateTime

func NewDateTimeForRFC3339

func NewDateTimeForRFC3339(tStr string) *DateTime

func NewDateTimeForTime

func NewDateTimeForTime(t time.Time) *DateTime

func NewDateTimeWithDate

func NewDateTimeWithDate(date *Date) *DateTime

func NewDateTimeWithTimeAndTimeZone

func NewDateTimeWithTimeAndTimeZone(tt time.Time, abbreviation string, offset *int) *DateTime

func (*DateTime) IANAName

func (dt *DateTime) IANAName() string

IANAName returns the IANA timezone name (e.g., "America/Los_Angeles") for this DateTime. Delegates to TimeZone.IANAName().

func (*DateTime) Location

func (dt *DateTime) Location() *time.Location

func (*DateTime) String

func (dt *DateTime) String() string

func (*DateTime) ToTime

func (dt *DateTime) ToTime() *time.Time

type DateTimeRange

type DateTimeRange struct {
	Start *DateTime
	End   *DateTime
}

A DateTimeRange represents a range of dates and times with time zones.

This type DOES include location information.

func NewRange

func NewRange(start *DateTime, end *DateTime) *DateTimeRange

func NewRangeWithStart

func NewRangeWithStart(startDT *DateTime) *DateTimeRange

func NewRangeWithStartDate

func NewRangeWithStartDate(startD *Date) *DateTimeRange

func NewRangeWithStartEndDates

func NewRangeWithStartEndDates(startD *Date, endD *Date) *DateTimeRange

func (*DateTimeRange) AddDate

func (rng *DateTimeRange) AddDate(years int, months int, days int) *DateTimeRange

func (*DateTimeRange) IANAName

func (rng *DateTimeRange) IANAName() string

IANAName returns the IANA timezone name (e.g., "America/Los_Angeles") for this range. Uses the Start datetime's timezone.

func (DateTimeRange) String

func (rng DateTimeRange) String() string

type DateTimeRanges

type DateTimeRanges struct {
	Items []*DateTimeRange
}

A DateTimes represents a sequence of date and time ranges. It's the expected result of parsing a string for datetimes.

This type DOES include location information.

func AppendDateTimeRanges

func AppendDateTimeRanges(rngs *DateTimeRanges, rng *DateTimeRange) *DateTimeRanges

func NewRanges

func NewRanges(rngs ...*DateTimeRange) *DateTimeRanges

func NewRangesWithStartDateTimes

func NewRangesWithStartDateTimes(starts ...*DateTime) *DateTimeRanges

func NewRangesWithStartDates

func NewRangesWithStartDates(starts ...*Date) *DateTimeRanges

func NewRangesWithStartEndDateTimes

func NewRangesWithStartEndDateTimes(start *DateTime, end *DateTime) *DateTimeRanges

func NewRangesWithStartEndDates

func NewRangesWithStartEndDates(start *Date, end *Date) *DateTimeRanges

func NewRangesWithStartEndRanges

func NewRangesWithStartEndRanges(start *DateTimeRange, end *DateTimeRange) *DateTimeRanges

NewRangesWithStartEndRanges fills in the days between start and end. For example a start of "Feb 1" and end of "Feb 4" is filled in with "Feb 2" and "Feb 3".

func Parse

func Parse(minDateTime *DateTime, dateMode string, in string) (*DateTimeRanges, error)

func (*DateTimeRanges) String

func (rngs *DateTimeRanges) String() string

type Time

type Time struct {
	Hour       int // The hour of the day in 24-hour format; range [0-23]
	Minute     int // The minute of the hour; range [0-59]
	Second     int // The second of the minute; range [0-59]
	Nanosecond int // The nanosecond of the second; range [0-999999999]
}

A Time represents a time with nanosecond precision.

This type does not include location information, and therefore does not describe a unique moment in time.

This type exists to represent the TIME type in storage-based APIs like BigQuery. Most operations on Times are unlikely to be meaningful. Prefer the DateTime type.

func NewAMTime

func NewAMTime(hourAny any, minuteAny any, secondAny any, nsAny any) *Time

func NewPMTime

func NewPMTime(hourAny any, minuteAny any, secondAny any, nsAny any) *Time

func NewTime

func NewTime(hourAny any, minuteAny any, secondAny any, nsAny any) *Time

func (*Time) String

func (t *Time) String() string

String returns the date in the format described in ParseTime. If Nanoseconds is zero, no fractional part will be generated. Otherwise, the result will end with a fractional part consisting of a decimal point and nine digits.

type TimeZone

type TimeZone struct {
	Name         string
	Abbreviation string
	Offset       string
}

func NewTimeZone

func NewTimeZone(nameAny any, abbrevAny any, offsetAny any) *TimeZone

func (*TimeZone) IANAName

func (tz *TimeZone) IANAName() string

IANAName returns the IANA timezone name (e.g., "America/Los_Angeles") for this TimeZone. It checks Name first (if it's already an IANA name), then falls back to looking up the Abbreviation in PreferredLocationNamesByAbbrev. Returns empty string if no IANA name can be determined.

func (*TimeZone) String

func (tz *TimeZone) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL