Git Product home page Git Product logo

synchro's Introduction

๐Ÿ•ฐ๏ธ Synchro: Timezone-typesafe date and time framework for Go

test codecov Go Reference

This is inspired by Rust chrono

Features

  • Timezone-typesafe date and time handling
  • Easy conversion between time zones
  • Support for common date and time operations
  • Compatible with the standard time package
  • Full compatible with ISO8601 (GoDoc)
    • โœ… Dates
      • Years
      • Calendar dates
      • Week dates
      • Quarter dates
      • Ordinal dates
    • โœ… Times
    • โœ… Combined date and time representations
    • โœ… Durations
    • โœ… Time intervals
      • Repeating intervals
    • Note: This package can be used as civil time.
      • Civil time is a time-zone-independent representation of time that follows the rules of the proleptic Gregorian calendar with exactly 24-hour days, 60-minute hours, and 60-second minutes.

Installation

To install Synchro, use go get:

go get github.com/Code-Hex/synchro

Synopsis

To use Synchro, import it in your Go code:

package main

import (
    "fmt"

    "github.com/Code-Hex/synchro"
    "github.com/Code-Hex/synchro/tz"
)

func main() {
    // The current UTC time is fixed to `2023-09-02 14:00:00`.
    utcNow := synchro.Now[tz.UTC]()
    fmt.Println(utcNow)

    jstNow := synchro.Now[tz.AsiaTokyo]()
    fmt.Println(jstNow)
    // Output:
    // 2009-11-10 23:00:00 +0000 UTC
    // 2009-11-11 08:00:00 +0900 JST
}

https://go.dev/play/p/Ql3CM7NLfj0

Please refer to the numerous usage examples on GoDoc for reference.

Utilities

We also have a wide range of very useful utilities!!

If you have a feature request, please open an issue. It would be great if you could provide relevant examples or links that could be helpful.

TODO

  • Support database/sql
  • Support i18n
  • Optimization

Contributing

Contributions to Synchro are welcome!

To contribute, please fork the repository and submit a pull request.

License

Synchro is licensed under the MIT License. See LICENSE for more information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.