Giter VIP home page Giter VIP logo

time_iso's Introduction

time_iso

A time formatting module for golang with iso 8601 in mind.

Motivation

In order to format time in golang you have to give a layout defined by a specific time, e.g.

now := time.Now()
now.Format("Mon, 02 Jan 2006 15:04:05 MST")

And yeah, it has to be January second, 2006 at 23:04:05 UTC (but in MST)

Usage / Example

To do the same thing in the Motivation we'll do:

now := time_iso.Time{time.Now()} // or time_iso.Now()
now.Format("DDD, DD MMM YYYY hh:mm:ss ZZZ")

Formats

  • DD: A two-digit day of that month, 01 through 31
  • DDD: A three-letter abbreviation for day of the week, e.g. Fri
  • DDDD: A day of the week spelled out in full, e.g. Friday
  • MM: A two-digit month of the year, 01 through 12
  • MMM: A three-letter abbreviation for month, e.g. Mar
  • YY: A two-digit year, e.g. 21
  • YYYY: A four-digit year, 0000 through 9999
  • Z: The zone designator for the zero UTC offset in the form ±[hh][mm]
  • ZZZ: The zone designator name, e.g. MST
  • _D: One-digit day of the month for days below 10, e.g. _2
  • hh: A zero-padded hour between 00 and 23
  • mm: A zero-padded minute between 00 and 59
  • ss: A zero-padded second between 00 and 60 (where 60 is only used to denote an added leap second
  • sss: A zero-padded millisecond between 000 and 999

time_iso's People

Contributors

donno2048 avatar

Watchers

 avatar  avatar

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.