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
- Variables
- func CleanTextLine(s string) string
- func DateMode(tz *TimeZone) string
- func HasStartMonthAndDay(rngs *DateTimeRanges) bool
- func NewDatetimeLexer(input string) *datetimeLexer
- func SetDebug(enabled bool)
- type Date
- func NewDateFromRaw(d *Date, tz *TimeZone) *Date
- func NewRawDateFromAmbiguous(weekdayAny any, first string, last string, yearAny any) *Date
- func NewRawDateFromDMY(dayAny any, monthAny any, yearAny any) *Date
- func NewRawDateFromDsMYs(daysAny []string, monthAny any, yearAny any) []*Date
- func NewRawDateFromMDY(monthAny any, dayAny any, yearAny any) *Date
- func NewRawDateFromMDsYs(monthAny any, daysAny []string, yearAny any) []*Date
- func NewRawDateFromRelative(relativeName string) *Date
- func NewRawDateFromWDMY(weekdayAny any, dayAny any, monthAny any, yearAny any) *Date
- func NewRawDateFromWMDY(weekdayAny any, monthAny any, dayAny any, yearAny any) *Date
- func NewRawDateFromYMD(yearAny any, monthAny any, dayAny any) *Date
- type DateTime
- func NewDateTime(d *Date, t *Time, tz *TimeZone) *DateTime
- func NewDateTimeForNow() *DateTime
- func NewDateTimeForRFC1123Z(tStr string) *DateTime
- func NewDateTimeForRFC3339(tStr string) *DateTime
- func NewDateTimeForTime(t time.Time) *DateTime
- func NewDateTimeWithDate(date *Date) *DateTime
- func NewDateTimeWithTimeAndTimeZone(tt time.Time, abbreviation string, offset *int) *DateTime
- type DateTimeRange
- type DateTimeRanges
- func AppendDateTimeRanges(rngs *DateTimeRanges, rng *DateTimeRange) *DateTimeRanges
- func NewRanges(rngs ...*DateTimeRange) *DateTimeRanges
- func NewRangesWithStartDateTimes(starts ...*DateTime) *DateTimeRanges
- func NewRangesWithStartDates(starts ...*Date) *DateTimeRanges
- func NewRangesWithStartEndDateTimes(start *DateTime, end *DateTime) *DateTimeRanges
- func NewRangesWithStartEndDates(start *Date, end *Date) *DateTimeRanges
- func NewRangesWithStartEndRanges(start *DateTimeRange, end *DateTimeRange) *DateTimeRanges
- func Parse(minDateTime *DateTime, dateMode string, in string) (*DateTimeRanges, error)
- type Time
- type TimeZone
Constants ¶
const A = 57347
const ADD = 57348
const AM = 57349
const AMP = 57350
const AND = 57351
const AT = 57352
const BEGINNING = 57353
const CALENDAR = 57354
const COLON = 57355
const COMMA = 57356
const DATE = 57357
const DATES = 57358
const DEC = 57359
const FROM = 57360
const GOOGLE = 57361
const ICS = 57362
const IDENT = 57389
const ILLEGAL = 57346
const IN = 57363
const INT = 57390
const LPAREN = 57364
const MONTH_NAME = 57391
const NEXT = 57365
const OF = 57366
const ON = 57367
const ORD_IND = 57368
const P = 57370
const PART = 57369
const PERIOD = 57372
const PM = 57371
const QUO = 57373
const RELATIVE_DAY = 57395
const RPAREN = 57374
const SAVE = 57375
const SEMICOLON = 57376
const SUB = 57377
const T = 57379
const TH = 57380
const THE = 57381
const THIS = 57382
const THROUGH = 57378
const TILL = 57383
const TIME = 57384
const TIME_NAME = 57392
const TIME_ZONE = 57393
const TIME_ZONE_ABBREV = 57394
const TO = 57385
const UNTIL = 57386
const WEEKDAY_NAME = 57396
const WEEKDAY_SHORT_NAME = 57397
const WHEN = 57387
const YEAR = 57398
const Z = 57388
Variables ¶
var DateModeNorthAmerican = "na"
North American tends to parse dates as month-day-year.
var DateModeNorthAmericanCountryCodes = map[string]bool{"CA": true, "US": true}
var DateModeRest = "rest"
var DateModeUnknown = ""
var DoDebug = false
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 HasStartMonthAndDay ¶
func HasStartMonthAndDay(rngs *DateTimeRanges) bool
func NewDatetimeLexer ¶
func NewDatetimeLexer(input string) *datetimeLexer
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 NewRawDateFromAmbiguous ¶
func NewRawDateFromDsMYs ¶
func NewRawDateFromMDsYs ¶
func NewRawDateFromRelative ¶
func NewRawDateFromWDMY ¶
func NewRawDateFromWMDY ¶
type DateTime ¶
A DateTime represents a date and time with a time zone.
This type DOES include location information.
func NewDateTimeForNow ¶
func NewDateTimeForNow() *DateTime
func NewDateTimeForRFC1123Z ¶
func NewDateTimeForRFC3339 ¶
func NewDateTimeForTime ¶
func NewDateTimeWithDate ¶
type DateTimeRange ¶
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 (*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.
type TimeZone ¶
func (*TimeZone) IANAName ¶
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.