Skip to content

The gotime is a Go library for simplified date and time processing, offering intuitive parsing, formatting, and relative time calculations. It complements the standard time package with user-friendly features for real-world applications. This library is ideal for developers needing day-to-day date and time operations.

License

Notifications You must be signed in to change notification settings

maniartech/gotime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GoTime πŸ•πŸ•‘πŸ•’ Tested

Intuitive time manipulation for Go - Making date/time operations as simple as they should be.

GoTime extends Go's standard time package with human-friendly operations that developers actually need in real-world applications. It leverages Go's powerful time handling while providing an intuitive API that makes working with dates and times a breeze.

Quick Example

import "github.com/maniartech/gotime"

// Intuitive formatting - no more "2006-01-02"!
formatted := gotime.Format(time.Now(), "yyyy-mm-dd hh:ii:ss")
// β†’ "2025-07-07 14:30:45"

// Easy format conversion
converted, _ := gotime.Convert("07/07/2025", "mm/dd/yyyy", "mmmm dt, yyyy")
// β†’ "July 7th, 2025"

// Human-readable relative time
timeAgo := gotime.TimeAgo(time.Now().Add(-5 * time.Minute))
// β†’ "5 minutes ago"

// Simple date arithmetic
nextBusinessDay := gotime.WorkDay(1, time.Now())
tenDaysFromNow := gotime.Days(10, time.Now())

Why GoTime?

The Problem: Go's time formatting is cryptic and error-prone

// Standard Go - Who remembers this?
time.Now().Format("2006-01-02 15:04:05")  // πŸ˜΅β€πŸ’«

The Solution: Human-readable format specifiers

// GoTime - Intuitive and memorable
gotime.Format(time.Now(), "yyyy-mm-dd hh:ii:ss")  // 😊

Key Benefits

What You Get Standard Go GoTime
Natural Syntax Cryptic 2006-01-02 NITES yyyy-mm-dd
Relative Time 15+ lines of code TimeAgo()
Format Conversion Parse + Format Convert()
Date Arithmetic Complex calculations WorkDay(), Days()
Business Logic Manual calculations Built-in helpers

Perfect For

  • Web APIs - Consistent date formatting across endpoints
  • Reports - Human-readable timestamps and date ranges
  • Business Logic - Working day calculations, relative dates
  • Data Processing - Converting between date formats
  • User Interfaces - "2 hours ago" style timestamps

Installation

go get github.com/maniartech/gotime

Requirements: Go 1.13+ β€’ Zero dependencies β€’ TinyGo compatible*

Core Features

Intuitive Formatting

// Remember yyyy-mm-dd, not 2006-01-02
formatted := gotime.Format(time.Now(), "mmmm dt, yyyy")
// β†’ "July 7th, 2025"

Smart Date Parsing

date, _ := gotime.Parse("2025-07-07", "yyyy-mm-dd")
date, _ := gotime.Parse("07/07/2025", "mm/dd/yyyy")

One-Line Format Conversion

iso, _ := gotime.Convert("07/07/2025", "mm/dd/yyyy", "yyyy-mm-dd")
// β†’ "2025-07-07"

Human-Friendly Relative Time

gotime.TimeAgo(fiveMinutesAgo)  // β†’ "5 minutes ago"
gotime.TimeAgo(nextWeek)        // β†’ "Next week"

Business Date Calculations

nextBusinessDay := gotime.WorkDay(1, time.Now())
businessDaysCount := gotime.NetWorkDays(startDate, endDate)

Documentation

Complete Documentation

Quick Links

By Use Case

Quality & Reliability

  • Test Coverage 100% Test Coverage β€” Every function is thoroughly tested
  • Test Cases 250+ Automated Test Cases β€” Industry-grade reliability
  • βœ“ Production Ready β€” Used in real-world applications
  • βœ“ Zero Dependencies β€” Only uses Go standard library
  • βœ“ TinyGo Compatible β€” Works in embedded and WebAssembly*
  • βœ“ MIT Licensed β€” Free for commercial use

TinyGo Compatibility*

GoTime's core library is designed to be compatible with TinyGo for use in embedded and WebAssembly environments. Test helpers and some internal utilities use reflect and runtime and are not TinyGo compatible, but these are not required for end users. To build with TinyGo, you must use a Go version supported by TinyGo (currently Go 1.19–1.22). See examples/tinygo/main.go for a working example.

Contributing

Contributions are welcome! Please ensure your code includes tests and follows existing patterns.

Found an issue? Open an issue Want to contribute? See our contribution guidelines

License

MIT Licensed - see LICENSE for details.


Browse Documentation | Star on GitHub | Report Issues

About

The gotime is a Go library for simplified date and time processing, offering intuitive parsing, formatting, and relative time calculations. It complements the standard time package with user-friendly features for real-world applications. This library is ideal for developers needing day-to-day date and time operations.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •