Skip to content

Repository files navigation

AsiaTZ

AsiaTZ is a dependency-free Go package for converting fixed-offset Asian local clock times and complete date-times to UTC. It supports strict HH:mm and YYYY-MM-DD HH:mm:ss values.

AsiaTZ uses documented fixed offsets. It does not apply daylight-saving transitions, historical offset changes, or IANA time-zone database rules.

Installation

go get github.com/chengchuu/asiatz

AsiaTZ supports Go 1.19 and later.

Usage

package main

import (
	"fmt"
	"log"

	"github.com/chengchuu/asiatz"
)

func main() {
	utcDateTime, err := asiatz.ShanghaiDateTimeToUTC("2026-01-01 01:01:01")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(utcDateTime) // 2025-12-31 17:01:01
}

Use ToUTCDateTime for another fixed offset, including offsets with whole-minute fractions:

utcDateTime, err := asiatz.ToUTCDateTime(5.75, "2026-01-01 05:45:30")

Date-time conversions accept and return exactly YYYY-MM-DD HH:mm:ss, preserve seconds, and retain day, month, year, and leap-year rollover. DateTimeLayout exposes the matching Go layout.

The existing clock-time API remains available when calendar information is not needed:

utcTime, err := asiatz.ToUTC(5.5, "05:30")
// utcTime is "00:00"

Named conversions

Location Fixed offset Clock helper Date-time helper
Shanghai UTC+08:00 ShanghaiToUTC ShanghaiDateTimeToUTC
Tokyo UTC+09:00 TokyoToUTC TokyoDateTimeToUTC
Hong Kong UTC+08:00 HongKongToUTC HongKongDateTimeToUTC
Singapore UTC+08:00 SingaporeToUTC SingaporeDateTimeToUTC
Taipei UTC+08:00 TaipeiToUTC TaipeiDateTimeToUTC
Seoul UTC+09:00 SeoulToUTC SeoulDateTimeToUTC
Beijing UTC+08:00 BeijingToUTC BeijingDateTimeToUTC
Dubai UTC+04:00 DubaiToUTC DubaiDateTimeToUTC
Delhi UTC+05:30 DelhiToUTC DelhiDateTimeToUTC
Jakarta UTC+07:00 JakartaToUTC JakartaDateTimeToUTC
Bangkok UTC+07:00 BangkokToUTC BangkokDateTimeToUTC
Pyongyang UTC+09:00 PyongyangToUTC PyongyangDateTimeToUTC

Malformed or non-zero-padded values, invalid calendar values, and offsets that do not resolve to whole minutes return an error. ToUTC and named clock helpers return only HH:mm. ToUTCDateTime and named date-time helpers return the complete UTC date and time.

Documentation

Development

gofmt -w .
go mod tidy
go test ./...
go test -race ./...
go vet ./...
go build ./...
go run ./examples/basic
go run ./cmd/sitegen build
go run ./cmd/sitegen validate
go run ./cmd/sitegen preview

The generated GitHub Pages artifact is written to dist/pages, ignored by Git, and rebuilt in CI. Do not edit generated Pages files by hand.

Project-maintenance conventions are documented in AGENTS.md. The template-derived identity checklist is retained in guides/CUSTOMIZE.md.

Contributing

Bug reports and focused pull requests are welcome through the GitHub repository.

License

AsiaTZ is available under the MIT License. Vendored website dependencies are documented in guides/THIRD_PARTY_NOTICES.md.

About

A Go library for converting timezones and other utilities, with a focus on Asia Time Zone.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages