Categorygithub.com/invzhi/timex
repositorypackage
1.0.0
Repository: https://github.com/invzhi/timex.git
Documentation: pkg.go.dev

# README

timex

Go Reference Go Report Card codecov

šŸ“… A Go package for working with date.

Why use timex?

  • Self-contained type Date, focusing on date-specific operations.
  • Don't rely on type time.Time, avoid timezone-related issues.
  • Represent date format like YYYY-MM-DD instead of 2006-01-02.
  • Working with date type of MySQL or PostgreSQL directly.
  • Fast methods implementation of Date relative to time.Time.
Methodpackage timexpackage time
OrdinalDate4.07 ns/op6.28 ns/op
Date6.81 ns/op8.04 ns/op
WeekDay0.31 ns/op2.80 ns/op
ISOWeek7.52 ns/op9.80 ns/op
Add12.23 ns/op24.18 ns/op
AddDays0.31 ns/op3.12 ns/op
Sub0.31 ns/op6.53 ns/op
Parse34.72 ns/op55.47 ns/op
Format28.05 ns/op59.46 ns/op
MarshalJSON27.53 ns/op41.42 ns/op
UnmarshalJSON10.89 ns/op52.11 ns/op

Features

  • Fully-implemented type Date.
    • Zero value: January 1, year 1. Align with type time.Time.
    • Working with standard library: conversion with type time.Time.
    • Parsing & Formatting: conversion with formatted strings.
    • Getter: get year, quarter, month, day of year, day of month, day of week.
    • Manipulation: addition and subtraction with years, month, days.
    • Comparison: comparing dates with Before, After, Equal.
    • Serialization: JSON and database.

Getting Started

go get github.com/invzhi/timex

Reference