-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.html
161 lines (153 loc) · 8.65 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Fucking Go Date Format</title>
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.5.0/pure-min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.5.0/grids-responsive-old-ie-min.css">
<![endif]-->
<!--[if gt IE 8]><!-->
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.5.0/grids-responsive-min.css">
<!--<![endif]-->
<link rel="stylesheet" href="fgdf.css" type="text/css">
</head>
<body>
<div id="layout">
<div id="main">
<div class="header">
<h1>Fucking Go Date Format</h1>
<h2>Because I've used <code>strftime</code> a million times before</h2>
</div>
<div class="content">
<div id="translator" class="pure-g">
<div class="pure-u-1-1 pure-u-md-11-24">
<input id="strftime" type="text" value="%B %e, %Y" />
</div>
<div id="arrow" class="pure-u-1-1 pure-u-md-2-24">
→
</div>
<div class="pure-u-1-1 pure-u-md-11-24">
<input id="output" type="text" readonly value="" />
</div>
</div>
<div id="definitions" class="pure-g">
<div class="pure-u-1-1 pure-u-md-12-24">
<dl>
<dt>%a</dt>
<dd class="pure-u-16-24">The abbreviated weekday name ("Sun")</dd>
<dt>%A</dt>
<dd class="pure-u-16-24">The full weekday name ("Sunday")</dd>
<dt>%b</dt>
<dd class="pure-u-16-24">The abbreviated month name ("Jan")</dd>
<dt>%B</dt>
<dd class="pure-u-16-24">The full month name ("January")</dd>
<dt>%d</dt>
<dd class="pure-u-16-24">Day of the month (01..31)</dd>
<dt>%e</dt>
<dd class="pure-u-16-24">Day of the month with a leading blank instead of zero ( 1..31)</dd>
<dt>%m</dt>
<dd class="pure-u-16-24">Month of the year (01..12)</dd>
<dt>%y</dt>
<dd class="pure-u-16-24">Year without a century (00..99)</dd>
<dt>%Y</dt>
<dd class="pure-u-16-24">Year with century</dd>
</dl>
</div>
<div class="pure-u-1-1 pure-u-md-12-24">
<dl>
<dt>%H</dt>
<dd class="pure-u-16-24">Hour of the day, 24-hour clock (00..23)</dd>
<dt>%I</dt>
<dd class="pure-u-16-24">Hour of the day, 12-hour clock (01..12)</dd>
<dt>%l</dt>
<dd class="pure-u-16-24">Hour of the day, 12-hour clock without a leading zero (1..12)</dd>
<dt>%M</dt>
<dd class="pure-u-16-24">Minute of the hour (00..59)</dd>
<dt>%P</dt>
<dd class="pure-u-16-24">Meridian indicator ("am" or "pm")</dd>
<dt>%p</dt>
<dd class="pure-u-16-24">Meridian indicator ("AM" or "PM")</dd>
<dt>%S</dt>
<dd class="pure-u-16-24">Second of the minute (00..60)</dd>
<dt>%z</dt>
<dd class="pure-u-16-24">Time zone hour and minute offset from UTC</dd>
<dt>%Z</dt>
<dd class="pure-u-16-24">Time zone name</dd>
<dt>%%</dt>
<dd class="pure-u-16-24">Literal "%" character</dd>
</dl>
</div>
</div>
<div id="unsupported" class="pure-g">
<h4 class="pure-u-1-1">Codes not natively supported in Go</h4>
<div class="pure-u-1-1 pure-u-md-12-24">
<dl>
<dt>%j</dt>
<dd class="pure-u-16-24">Day of the year (001..366)<br>use <a href="http://godoc.org/time#Time.YearDay">YearDay()</a> instead</dd>
<dt>%U</dt>
<dd class="pure-u-16-24">Week number of the current year, starting with the first Sunday as the first day of the first week (00..53)</dd>
<dt>%W</dt>
<dd class="pure-u-16-24">Week number of the current year, starting with the first Monday as the first day of the first week (00..53)<br>use <a href="http://godoc.org/time#Time.ISOWeek">ISOWeek()</a> instead</dd>
<dt>%w</dt>
<dd class="pure-u-16-24">Day of the week (Sunday is 0, 0..6)<br>use <a href="http://godoc.org/time#Time.Weekday">Weekday()</a> instead</dd>
</dl>
</div>
<div class="pure-u-1-1 pure-u-md-12-24">
<dl>
<dt>%X</dt>
<dd class="pure-u-16-24">Preferred representation for the time alone, no date</dd>
<dt>%x</dt>
<dd class="pure-u-16-24">Preferred representation for the date alone, no time</dd>
<dt>%c</dt>
<dd class="pure-u-16-24">The preferred local date and time representation</dd>
</dl>
</div>
</div>
<div id="why">
<h3>But...why?</h3>
<p>
Having used the <code>strftime</code> in many other languages (shell, ruby, python, c),
Go's date formatting was frustratingly different — frustrating mostly because I'm
too lazy to learn a new date format. I wanted to build this site to let me be
lazy and continue writing <code>strftime</code> format strings in Go.
</p>
<p>
Ironically, I can now write Go date format strings now after building this site. You win this
time <a href="https://groups.google.com/forum/#!msg/golang-nuts/IoPQESsWggI/cyHQMDhVDUsJ">Russ Cox</a>.
</p>
<p>
If you <em>really</em> need <code>strftime</code> functionality, there are a few
<a href="http://godoc.org/?q=strftime">open source</a> alternatives.
(Courtesy of <a href="https://news.ycombinator.com/item?id=8944747">Andrew Gerrand</a>). Or just use
this <a href="https://twitter.com/_saljam/status/559499590383046656">bash script</a>.
</p>
</div>
<div id="footer">
Made by <a href="http://bwong.net/">Benny Wong</a>.<br />
Not a fan of profanity? <a href="http://flippinggodateformat.com">Flipping Go Date Format</a> also works.<br />
Inspired by <a href="http://fuckingblocksyntax.com/">Fucking Block Syntax</a> by my buddy
<a href="http://lazerwalker.com/">Lazer-Walker</a>.
Code definitions from <a href="http://www.strfti.me/">strfti.me</a>.<br />
If you want to write Go for millions of daily active users, <a href="http://timehop.com/jobs">Timehop</a> is hiring.<br />
This is webpage is <a href="https://github.com/bdotdub/fuckinggodateformat">open source</a>.
We also do some (arguably) more useful open source stuff — check it out at
<a href="http://garage.timehop.com">Timehop's Garage</a>.
</div>
</div>
</div>
</div>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="fgdf.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-2245468-7', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>