date

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

README

format/date

Date formatting based on unicode specification https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table Inspired by https://github.com/date-fns/date-fns

import (
  "fmt"
  "github.com/datasweet/format/date"
)

func main() {
  // The numeric time represents Thu Feb  4 21:00:57.012345600 PST 2009
  tm := time.Unix(0, 1233810057012345600)
  
  // Format with local timezone Europe/Paris
  // Pattern "yyyy-MM-ddTHH:mm:ssXXX" = RFC3339
  fmt.Println(date.Format(language.French, tm, "yyyy-MM-ddTHH:mm:ssXXX"))
  // Output: 2009-02-05T06:00:57+01:00
}

Patterns

  • a: AM, PM
  • b: AM, PM, noon, midnight
  • c: Stand-alone local day of week <!> not implemented
  • d: Day of month
  • e: Local day of week
  • g: Modified Julian day <!> not implemented
  • h: Hour [1-12]
  • j: Localized hour w/ day period <!> not implemented
  • k: Hour [1-24]
  • m: Minute
  • q: Stand-alone quarter
  • r: Related Gregorian year <!> not implemented
  • s: Second
  • t: timestamp in millisecond custom <!> custom code
  • u: Extended year
  • v: Timezone (generic non-locat.) <!> not implemented
  • w: Local week of year <!> not implemented
  • x: Timezone (ISO-8601 w/o Z)
  • y: Year (abs)
  • z: Timezone (specific non-locat.)
  • A: Milliseconds in day <!> not implemented
  • B: Flexible day period
  • C: Localized hour w/ day period <!> not implemented
  • D: Day of year
  • E: Day of week
  • F: Day of week in month <!> not implemented
  • G: Era
  • H: Hour [0-23]
  • J: Localized hour w/o day period <!> not implemented
  • K: Hour [0-11]
  • L: Stand-alone month
  • M: Month
  • O: Timezone (GMT)
  • Q: Quarter
  • S: Fraction of second
  • U: Cyclic year <!> not implemented
  • V: Timezone (location) <!> not implemented
  • W: Week of month <!> not implemented
  • X: Timezone (ISO-8601)
  • Y: Local week-numbering year
  • Z: Timezone (aliases)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(lang language.Tag, t time.Time, format string) string

Format the date with a unicode format https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL