Created
May 10, 2018 22:36
-
-
Save adamluzsi/9717bea57e8b2ef4a791099426503181 to your computer and use it in GitHub Desktop.
Golang Time Format creating cheat sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2010 The Go Authors. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
package time | |
const ( | |
_ = iota | |
stdLongMonth = iota + stdNeedDate // "January" | |
stdMonth // "Jan" | |
stdNumMonth // "1" | |
stdZeroMonth // "01" | |
stdLongWeekDay // "Monday" | |
stdWeekDay // "Mon" | |
stdDay // "2" | |
stdUnderDay // "_2" | |
stdZeroDay // "02" | |
stdHour = iota + stdNeedClock // "15" | |
stdHour12 // "3" | |
stdZeroHour12 // "03" | |
stdMinute // "4" | |
stdZeroMinute // "04" | |
stdSecond // "5" | |
stdZeroSecond // "05" | |
stdLongYear = iota + stdNeedDate // "2006" | |
stdYear // "06" | |
stdPM = iota + stdNeedClock // "PM" | |
stdpm // "pm" | |
stdTZ = iota // "MST" | |
stdISO8601TZ // "Z0700" // prints Z for UTC | |
stdISO8601SecondsTZ // "Z070000" | |
stdISO8601ShortTZ // "Z07" | |
stdISO8601ColonTZ // "Z07:00" // prints Z for UTC | |
stdISO8601ColonSecondsTZ // "Z07:00:00" | |
stdNumTZ // "-0700" // always numeric | |
stdNumSecondsTz // "-070000" | |
stdNumShortTZ // "-07" // always numeric | |
stdNumColonTZ // "-07:00" // always numeric | |
stdNumColonSecondsTZ // "-07:00:00" | |
stdFracSecond0 // ".0", ".00", ... , trailing zeros included | |
stdFracSecond9 // ".9", ".99", ..., trailing zeros omitted | |
stdNeedDate = 1 << 8 // need month, day, year | |
stdNeedClock = 2 << 8 // need hour, minute, second | |
stdArgShift = 16 // extra argument in high bits, above low stdArgShift | |
stdMask = 1<<stdArgShift - 1 // mask out argument | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment