Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
153 lines (140 sloc) 3.19 KB
Things that our formatetr handles automatically:
flags:
- no padding
_ pad with spaces
0 pad with zeros
^ use upper case
# use opposite case
auto non-date characters:
% percent
n newline
t tab
formatter selection: (24hour/etc)
%1 - %999...
alternate selection: (Week-based year, etc)
%~1 - %~...
manipulation:
[] = common i.e. %[ymd], %[atrean]
{} = filter i.e. %{nd}d → 2nd, %{str}d → two, %{str|nd}d → second
() = args for filter i.e. "some%{s}(foo)(bar)d" → somefoo (if d is 1) or somebar (if d is plural)
directives:
rules:
yY/m/d for date
H:M:S:N/F for date
;/: for timezone
a = Sun = %1~b
A = Sunday = %1~B
b = Jan
B = January
c = {complete} = %a %b %-d, %T %Y
C = century
d = day of month
D = {date} = %d/%m/%Y
e = %_d
E =
f = {full year} = %Y-%m-%d
F = fraction (detail)
g = week year (2 digit)
G = week year (4 digit)
h =
H = hour
i = abbreviated hour name (not used in gregorian)
I = hour name (i.e. 12 hour)
j = day of year
J =
k =
K =
l =
L =
m = month
M = minute
n -
N = nanoseconds
p = day qualifer (am/pm)
P =
r = {long time} = %H:%M:%S.%N
R = {full time} = %H:%M:%S.%F
s = seconds since zero
S = seconds
t -
T = {time} = %H:%M:%S
u = day of week
U = week in year
v =
V = Week number in week year
w = day of week
W = week in year
x =
X = {short time} = %H:%M
y = year in century
Y = year
z = timezone abbreviation
Z = timezone full name
; = timezone (±hhmm)
: = timezone ±hh:mm
:: = timezone ±hh:mm:ss
::: = timezone auto-precision
To build a formatter, we need:
Integer -> (Year, Integer)
Year -> Integer -> Day
Year -> Integer -> Integer -> Time
Day -> Short
Weekday -> Long
Month -> Short
Month -> Long
YMD -> (Week, Year)
Hour -> Maybe Qualifier (am/pm)
Nanosecond cap
HMSX -> Timezone abbreviation
Axed:
e - %_d
h - %b
k - %_H
l - %_I
P - %^p
How unix "date" works:
%% - %
%a - Sun
%A - Sunday
%b - Jan
%B - January
%c - Sun Jan 1 23:59:59 1999
%C - 19 (century)
%d - 01 (day of month)
%D - %m/%d/%y
%e - %_d
%F - %Y-%m-%d
%g - last two digits of year of ISO week number (?)
%G - year of ISO week number (?)
%h - %b
%H - hour (00..23)
%I - hour (01..12)
%j - day of year (001..366)
%k - %_H
%l - %_I
%m - month (01..12)
%M - minute (00..59)
%n - newline
%N - nanoseconds (integer, < billion)
%p - AM/PM
%P - am/pm
%r - locale time (nonmilitary) 11:59:04 PM
%R - 24:59
%s - seconds since epoch
%S - second (00..60)
%t - tab
%T - %H:%M:%s
%u - Day of week (1..7) 1=Monday
%U - week in year, Sunday first (00..53)
%V - ISO week number, Monday first (01..53)
%w - day of week (0..6) 0=Sunday
%W - week in year, Monday first (00..53)
%x - locale date 12/31/99
%X - locale time (military) 23:59:04 PM
%y - last two digits of year (0..99)
%Y - Year
%z - +hhmm numeric time zone (eg -0400)
%:z - +hh:mm numeric time zone (eg -04:00)
%::z - +hh:mm:ss numeric time zone
%:::z - time zone to necessary precision eg -04, +05:30
%Z - time zoen abbreviation (EDT)