fmtdate

MS Excel (TM) syntax for Go time/date

Github stars Tracking Chart

fmtdate

Build Status Total views

100% test coverage (that was easy :-))

fmtdate provides a date formatter and parser using the syntax of Microsoft Excel (TM).

Additionally it offers default conversions for date time and datetime.

Why?

Microsoft Excel (TM) has a well known syntax for date formatting, that more
memorable than the syntax chosen in the time package in the go library.

Usage


	package main
	import (
		"github.com/metakeule/fmtdate"
		"fmt"
	)

	func main() {
		date := fmtdate.Format("DD.MM.YYYY", time.Now())
		fmt.Println(date)

		var err
		date, err = fmtdate.Parse("M/D/YY", "2/3/07")
		fmt.Println(date, err)
	}

For json


    package main

    import (
        "github.com/metakeule/fmtdate"
        "fmt"
        "encoding/json"
    )

    type Person struct {
        Name string
        BirthDay fmtdate.TimeDate
    }

    func main() {
        bday, err := fmtdate.NewTimeDate("YYYY-MM-DD", "2000-12-04")
        // do error handling
        paul := &Person{"Paul", bday}

        data, err := json.Marshal(paul)
        // do error handling
    }

Placeholders

M    - month (1)
MM   - month (01)
MMM  - month (Jan)
MMMM - month (January)
D    - day (2)
DD   - day (02)
DDD  - day (Mon)
DDDD - day (Monday)
YY   - year (06)
YYYY - year (2006)
hh   - hours (15)
mm   - minutes (04)
ss   - seconds (05)

AM/PM hours: 'h' followed by optional 'mm' and 'ss' followed by 'pm', e.g.

hpm        - hours (03PM)
h:mmpm     - hours:minutes (03:04PM)
h:mm:sspm  - hours:minutes:seconds (03:04:05PM)

Time zones: a time format followed by 'ZZZZ', 'ZZZ' or 'ZZ', e.g.

hh:mm:ss ZZZZ (16:05:06 +0100)
hh:mm:ss ZZZ  (16:05:06 CET)
hh:mm:ss ZZ   (16:05:06 +01:00)

Documentation

see http://godoc.org/github.com/metakeule/fmtdate

Main metrics

Overview
Name With Ownerlmatteis/peer-tweet
Primary LanguageJavaScript
Program languageGo (Language Count: 3)
Platform
License:MIT License
所有者活动
Created At2016-02-05 23:32:21
Pushed At2016-03-10 22:56:11
Last Commit At2016-03-10 23:55:18
Release Count2
Last Release Namev0.1.1 (Posted on )
First Release Namev0.1.0 (Posted on )
用户参与
Stargazers Count872
Watchers Count38
Fork Count48
Commits Count81
Has Issues Enabled
Issues Count9
Issue Open Count5
Pull Requests Count1
Pull Requests Open Count1
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private