datetime

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package datetime provides timezone and timestamp parsing utilities for cencli.

This file defines the supported timezone identifiers that can be used for the default-tz configuration option. These timezones are used when parsing timestamp inputs that don't include explicit timezone information.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(input string, defaultTZ TimeZone) (time.Time, error)

Parse tries to parse a string into a time.Time. If the string is in RFC3339 format, it will be returned as-is. If the string does not specify a timezone, the default timezone will be used. If the string only specifies a date, the time will be set to 00:00:00.

Types

type TimeZone

type TimeZone string
const (
	// Core
	TimeZoneUTC TimeZone = "UTC"

	// America
	TimeZoneAmericaNewYork    TimeZone = "America/New_York"
	TimeZoneAmericaChicago    TimeZone = "America/Chicago"
	TimeZoneAmericaDenver     TimeZone = "America/Denver"
	TimeZoneAmericaLosAngeles TimeZone = "America/Los_Angeles"
	TimeZoneAmericaPhoenix    TimeZone = "America/Phoenix"
	TimeZoneAmericaToronto    TimeZone = "America/Toronto"
	TimeZoneAmericaSaoPaulo   TimeZone = "America/Sao_Paulo"
	TimeZoneAmericaMexicoCity TimeZone = "America/Mexico_City"
	TimeZoneAmericaAnchorage  TimeZone = "America/Anchorage"

	// Europe
	TimeZoneEuropeLondon   TimeZone = "Europe/London"
	TimeZoneEuropeParis    TimeZone = "Europe/Paris"
	TimeZoneEuropeBerlin   TimeZone = "Europe/Berlin"
	TimeZoneEuropeMadrid   TimeZone = "Europe/Madrid"
	TimeZoneEuropeRome     TimeZone = "Europe/Rome"
	TimeZoneEuropeMoscow   TimeZone = "Europe/Moscow"
	TimeZoneEuropeIstanbul TimeZone = "Europe/Istanbul"
	TimeZoneEuropeWarsaw   TimeZone = "Europe/Warsaw"

	// Asia
	TimeZoneAsiaTokyo     TimeZone = "Asia/Tokyo"
	TimeZoneAsiaShanghai  TimeZone = "Asia/Shanghai"
	TimeZoneAsiaSingapore TimeZone = "Asia/Singapore"
	TimeZoneAsiaHongKong  TimeZone = "Asia/Hong_Kong"
	TimeZoneAsiaBangkok   TimeZone = "Asia/Bangkok"
	TimeZoneAsiaKolkata   TimeZone = "Asia/Kolkata"
	TimeZoneAsiaSeoul     TimeZone = "Asia/Seoul"
	TimeZoneAsiaDubai     TimeZone = "Asia/Dubai"
	TimeZoneAsiaJerusalem TimeZone = "Asia/Jerusalem"

	// Oceania
	TimeZoneAustraliaSydney    TimeZone = "Australia/Sydney"
	TimeZoneAustraliaMelbourne TimeZone = "Australia/Melbourne"
	TimeZonePacificAuckland    TimeZone = "Pacific/Auckland"
	TimeZonePacificHonolulu    TimeZone = "Pacific/Honolulu"

	// Africa
	TimeZoneAfricaCairo        TimeZone = "Africa/Cairo"
	TimeZoneAfricaJohannesburg TimeZone = "Africa/Johannesburg"
	TimeZoneAfricaNairobi      TimeZone = "Africa/Nairobi"
	TimeZoneAfricaLagos        TimeZone = "Africa/Lagos"
)

func (*TimeZone) UnmarshalText

func (tz *TimeZone) UnmarshalText(text []byte) error