date

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 1 Imported by: 0

README

date

Pure calendar date arithmetic for Go and TinyGo: weekday-of-date, days-in-month, leap years, month names, YYYY-MM/YYYY-MM-DD keys -- no time zone, no JS interop, zero dependencies beyond tinywasm/fmt

Documentation

Overview

Package date is pure calendar arithmetic for Go and TinyGo: weekday of a date, days in a month, leap years, month names, and the "YYYY-MM"/ "YYYY-MM-DD" key format used across the tinywasm ecosystem to identify a month or a day. No time zone, no wall clock, no JS interop — for that, use github.com/tinywasm/time. Every function here is a pure computation over (year, month, day) ints, so it runs identically in WASM and on the backend, and needs no build-tag split.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMonths added in v0.0.2

func AddMonths(year, month, delta int) (int, int)

AddMonths adds delta months to (year, month), rolling the year over as needed — the only date arithmetic that depends on neither time zone nor the calendar (unlike day arithmetic, a month always has exactly 12 steps per year).

func DateKey added in v0.0.2

func DateKey(year, month, day int) string

DateKey formats (year, month, day) as "YYYY-MM-DD".

func DaysInMonth added in v0.0.2

func DaysInMonth(year, month int) int

DaysInMonth returns the number of days in month (1-12) for year.

func IsLeapYear added in v0.0.2

func IsLeapYear(year int) bool

IsLeapYear reports whether year is a leap year.

func MonthKey added in v0.0.2

func MonthKey(year, month int) string

MonthKey formats (year, month) as "YYYY-MM".

func MonthName added in v0.0.2

func MonthName(month int) string

MonthName returns month's Spanish name ("Enero".."Diciembre"), or "" if month is out of range. Switch, not a map — TinyGo.

func ParseMonthKey added in v0.0.2

func ParseMonthKey(s string) (year, month int)

ParseMonthKey reads "YYYY-MM" (or the "YYYY-MM-DD" form, ignoring the day); returns (0, 0) if s is not a valid month key.

func Weekday added in v0.0.2

func Weekday(year, month, day int) int

Weekday returns the day of week for a date (0 = Sunday … 6 = Saturday) using the Sakamoto algorithm: pure arithmetic, no time zone, no parsing — deterministic in WASM and on the backend.

Types

This section is empty.

Jump to

Keyboard shortcuts

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