/*
### isStandardTime([date])
alias `isSt`

If a date is at standard time (`now` is used if no `date` is specified)

jsk.tz.isStandardTime(new Date(2012, 1, 1)) // for North America/Eastern Time
=> true
517024
function isSt(date, testOffset) {
      date = date || new Date();
      var offset = testOffset || date.getTimezoneOffset();
      return offset == jsk.invertedSt();
    }
1366213
func (t *Time) StrToDate(date, format string) bool {
	ctx := make(map[string]int)
	var tm mysqlTime
	if !strToDate(&tm, date, format, ctx) {
		t.Time = ZeroTime
		t.Type = mysql.TypeDatetime
		t.Fsp = 0
		return false
	}
	if err := mysqlTimeFix(&tm, ctx); err != nil {
		return false
	}

	t.Time = tm
	t.Type = mysql.TypeDatetime
	if t.check() != nil {
		return false
	}
	return true
}
116992
func (dtp *DefaultTimestampProvider) Now() Timestamp {
	return Timestamp{
		Time: uint64(time.Now().Unix()),
	}
}
96674
func IsTypeTime(tp byte) bool {
	return tp == mysql.TypeDatetime || tp == mysql.TypeDate || tp == mysql.TypeTimestamp
}
989725
func (a *CompositeAggregationDateHistogramValuesSource) TimeZone(timeZone string) *CompositeAggregationDateHistogramValuesSource {
	a.timeZone = timeZone
	return a
}
117946
func is12HourTime(format string) bool {
	return strings.Contains(format, "am/pm") || strings.Contains(format, "AM/PM") || strings.Contains(format, "a/p") || strings.Contains(format, "A/P")
}
1140321
func parseTime(t interface{}) (time.Time, error) {
	var err error
	var calcTime time.Time
	switch v := t.(type) {
	case string:
		if calcTime, err = time.Parse(TimeFormat, v); err != nil {
			return time.Time{}, errors.New("cannot parse string time")
		}
	case int64:
		calcTime = time.Unix(v, 0).UTC()
	default:
		return time.Time{}, errors.New("arg must be a timestamp")
	}
	return calcTime, nil
}
216473
func (p *Parser) parseTimestamp() (time.Time, error) {
	var ts time.Time

	if p.buff[p.cursor] == NILVALUE {
		p.cursor++
		return ts, nil
	}

	fd, err := parseFullDate(p.buff, &p.cursor, p.l)
	if err != nil {
		return ts, err
	}

	if p.buff[p.cursor] != 'T' {
		return ts, ErrInvalidTimeFormat
	}

	p.cursor++

	ft, err := parseFullTime(p.buff, &p.cursor, p.l)
	if err != nil {
		return ts, syslogparser.ErrTimestampUnknownFormat
	}

	nSec, err := toNSec(ft.pt.secFrac)
	if err != nil {
		return ts, err
	}

	ts = time.Date(
		fd.year,
		time.Month(fd.month),
		fd.day,
		ft.pt.hour,
		ft.pt.minute,
		ft.pt.seconds,
		nSec,
		ft.loc,
	)

	return ts, nil
}
696701
func (namespace *Namespace) PushNowTSDS_BaseTime(key string, val string) bool {
	return namespace.PushTSDS_BaseTime(key, val, goltime.TimestampNow())
}
1207055
func (pt *ParseTime) US(value string) (time.Time, error) {
	t, _, err := parseUS(value, pt.location)
	return t, err
}
117023
func (c *Carbon) IsSameDay(carb *Carbon) bool {
	n := nowIn(c.Location())
	if carb != nil {
		n = carb
	}

	return c.Year() == n.Year() && c.Month() == n.Month() && c.Day() == n.Day()
}
1253193
func (s *Service) CheckTimestamp(timestampHeader string) (bool, error) {
	// convert unix timestamp string into time struct
	timestamp, err := strconv.ParseInt(timestampHeader, 10, 0)
	if err != nil {
		return false, fmt.Errorf("unable to parse %v: %v", s.config.TimestampHeaderName, timestampHeader)
	}

	now := s.clock.Now().UTC().Unix()

	// if timestamp is from the future, it's invalid
	if timestamp >= now+MaxSkewSec {
		return false, fmt.Errorf("timestamp header from the future; now: %v; %v: %v; difference: %v",
			now, s.config.TimestampHeaderName, timestamp, timestamp-now)
	}

	// if the timestamp is older than ttl - skew, it's invalid
	if timestamp <= now-int64(s.nonceCache.cacheTTL-MaxSkewSec) {
		return false, fmt.Errorf("timestamp header too old; now: %v; %v: %v; difference: %v",
			now, s.config.TimestampHeaderName, timestamp, now-timestamp)
	}

	return true, nil
}
1296277
func TimezoneOffsetNoDST(t time.Time) int {
	_, winterOffset := time.Date(t.Year(), 1, 1, 0, 0, 0, 0, t.Location()).Zone()
	_, summerOffset := time.Date(t.Year(), 7, 1, 0, 0, 0, 0, t.Location()).Zone()
	if winterOffset > summerOffset {
		winterOffset, summerOffset = summerOffset, winterOffset
	}
	return winterOffset
}
676843
func (c Calendar) parseDateTimeFormat(pattern string) ([]*datetimePatternComponent, error) {
	// every thing between single quotes should become a literal
	// all non a-z, A-Z characters become a literal
	// everything else, repeat character sequences become a component
	format := []*datetimePatternComponent{}
	for i := 0; i < len(pattern); {
		char := pattern[i : i+1]

		skip := false
		// for units we don't support yet, just skip over them
		for _, r := range datetimeFormatUnitCutset {
			if char == string(r) {
				skip = true
				break
			}
		}

		if skip {
			i++
			continue
		}

		if char == string(datetimeFormatLiteral) {
			// find the next single quote
			// create a literal out of everything between the quotes
			// and set i to the position after the second quote

			if i == len(pattern)-1 {
				return []*datetimePatternComponent{}, errors.New("malformed datetime format")
			}

			nextQuote := strings.Index(pattern[i+1:], string(datetimeFormatLiteral))
			if nextQuote == -1 {
				return []*datetimePatternComponent{}, errors.New("malformed datetime format")
			}

			component := &datetimePatternComponent{
				pattern:       pattern[i+1 : nextQuote+i+1],
				componentType: datetimePatternComponentLiteral,
			}

			format = append(format, component)
			i = nextQuote + i + 2
			continue

		}
		if (char >= "a" && char <= "z") || (char >= "A" && char <= "Z") {
			// this represents a format unit
			// find the entire sequence of the same character
			endChar := lastSequenceIndex(pattern[i:]) + i

			component := &datetimePatternComponent{
				pattern:       pattern[i : endChar+1],
				componentType: datetimePatternComponentUnit,
			}

			format = append(format, component)
			i = endChar + 1
			continue

		}
		if char == string(datetimeFormatTimeSeparator) {
			component := &datetimePatternComponent{
				// pattern:       c.TimeSeparator,
				pattern:       string(datetimeFormatTimeSeparator),
				componentType: datetimePatternComponentLiteral,
			}
			format = append(format, component)
			i++
			continue

		}

		component := &datetimePatternComponent{
			pattern:       char,
			componentType: datetimePatternComponentLiteral,
		}

		format = append(format, component)
		i++
		continue

	}

	return format, nil
}
16212
func ParseTimestamp(timestamp interface{}, format string) (time.Time, error) {
	return ParseTimestampWithLocation(timestamp, format, "UTC")
}
907160
@Override
  public boolean isTimeIncluded (final long timeStamp)
  {
    if (m_aExcludeAll == true)
    {
      return false;
    }

    // Test the base calendar first. Only if the base calendar not already
    // excludes the time/date, continue evaluating this calendar instance.
    if (super.isTimeIncluded (timeStamp) == false)
    {
      return false;
    }

    final Calendar cl = createJavaCalendar (timeStamp);
    final int day = cl.get (Calendar.DAY_OF_MONTH);

    return !(isDayExcluded (day));
  }
265388
func IsW3CDTF(timeStr string) bool {
	if !strings.Contains(timeStr, "T") {
		switch true {
		case IsYear(timeStr):
			return true
		case IsYearAndMonth(timeStr):
			return true
		case IsCompleteDate(timeStr):
			return true
		default:
			return false
		}
	} else {
		switch true {
		case IsCompleteDateWithMinutes(timeStr):
			return true
		case IsCompleteDateWithSeconds(timeStr):
			return true
		case IsCompleteDateWithFractionOfSecond(timeStr):
			return true
		default:
			return false
		}
	}
}