timezone

package
v0.0.0-...-57c9f0f Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertFormInputToICalFormat

func ConvertFormInputToICalFormat(dateStr, timeStr, originalICalValue string) (string, error)

ConvertFormInputToICalFormat converts form input to iCal format while preserving timezone context Uses the original iCal value to determine the correct output format

func FormDateDisplay

func FormDateDisplay(icalValue string) (string, error)

FormDateDisplay converts an iCal date value to user-friendly date string for forms

func FormTimeDisplay

func FormTimeDisplay(icalValue string) (dateStr, timeStr string, err error)

FormTimeDisplay converts an iCal datetime value to user-friendly local time strings for forms Returns separate date and time strings for form fields

func GetEventTimes

func GetEventTimes(event *ical.Event) (LocalTime, LocalTime, error)

GetEventTimes extracts both start and end times from an ical.Event as LocalTime

func IsValidEndTime

func IsValidEndTime(value string) bool

IsValidEndTime validates an end time string in any accepted format

func IsValidICalDate

func IsValidICalDate(value string) bool

IsValidICalDate validates an iCal date string format (for all-day events)

func IsValidICalDateTime

func IsValidICalDateTime(value string) bool

IsValidICalDateTime validates an iCal datetime string format

func IsValidStartTime

func IsValidStartTime(value string) bool

IsValidStartTime validates a start time string in any accepted format

func PopulateFormFromEvent

func PopulateFormFromEvent(event *ical.Event) (startDate, startTime, endDate, endTime string, err error)

PopulateFormFromEvent extracts display-friendly values from an ical.Event for form population Returns separate date and time strings that can be shown to the user

func PreserveTimezoneFormat

func PreserveTimezoneFormat(localTime LocalTime, originalValue string) string

PreserveTimezoneFormat formats a LocalTime for iCal storage while preserving the original format This prevents timezone corruption when updating events

func SetEventDateTimeProperty

func SetEventDateTimeProperty(event *ical.Event, propName string, localTime LocalTime, originalValue string)

SetEventDateTimeProperty safely sets a datetime property on an event while preserving timezone format

func ValidateICalTimeRange

func ValidateICalTimeRange(startValue, endValue string) error

ValidateICalTimeRange validates that two iCal time strings form a valid range

func ValidateTimeRange

func ValidateTimeRange(startTime, endTime LocalTime) error

ValidateTimeRange ensures end time is after start time

Types

type LocalTime

type LocalTime struct {
	time.Time
}

LocalTime is always in user's local timezone to prevent timezone bugs This type enforces that all calendar display operations use local time

func GetEventEndTime

func GetEventEndTime(event *ical.Event) (LocalTime, error)

GetEventEndTime extracts end time from an ical.Event as LocalTime

func GetEventStartTime

func GetEventStartTime(event *ical.Event) (LocalTime, error)

GetEventStartTime extracts start time from an ical.Event as LocalTime

func NewLocalTime

func NewLocalTime(t time.Time) LocalTime

NewLocalTime ensures time is in local timezone

func NewLocalTimeFromDateTime

func NewLocalTimeFromDateTime(dateStr, timeStr string) (LocalTime, error)

NewLocalTimeFromDateTime creates LocalTime from separate date and time strings

func ParseFormInput

func ParseFormInput(dateStr, timeStr string) (LocalTime, error)

ParseFormInput converts user form input (date + time strings) to LocalTime This is the safe way to handle user input, always interpreting as local time

func ParseICalDate

func ParseICalDate(icalValue string) (LocalTime, error)

ParseICalDate safely parses an iCal date value (for all-day events)

func ParseICalDateTime

func ParseICalDateTime(icalValue string) (LocalTime, error)

ParseICalDateTime safely parses an iCal datetime value into LocalTime Handles both UTC (20060102T150405Z) and local (20060102T150405) formats

func (LocalTime) Add

func (lt LocalTime) Add(d time.Duration) LocalTime

Add enforces local timezone on any arithmetic

func (LocalTime) AddDate

func (lt LocalTime) AddDate(years, months, days int) LocalTime

AddDate adds years, months, and days to the LocalTime

func (LocalTime) After

func (lt LocalTime) After(other LocalTime) bool

After checks if this time is after another LocalTime

func (LocalTime) Before

func (lt LocalTime) Before(other LocalTime) bool

Before checks if this time is before another LocalTime

func (LocalTime) Date

func (lt LocalTime) Date() (year int, month time.Month, day int)

Date returns the year, month, and day of the LocalTime

func (LocalTime) Equal

func (lt LocalTime) Equal(other LocalTime) bool

Equal checks if this time equals another LocalTime

func (LocalTime) Format

func (lt LocalTime) Format(layout string) string

Format always formats the time in local timezone

func (LocalTime) String

func (lt LocalTime) String() string

String returns a readable representation

func (LocalTime) Sub

func (lt LocalTime) Sub(other LocalTime) time.Duration

Sub returns duration between two LocalTimes

func (LocalTime) ToICalFormat

func (lt LocalTime) ToICalFormat(originalValue string) string

ToICalFormat formats time for iCal storage, preserving the original timezone context

func (LocalTime) ToUTC

func (lt LocalTime) ToUTC() time.Time

ToUTC converts the local time to UTC for storage in iCal format

Jump to

Keyboard shortcuts

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