Created
May 4, 2011 19:59
-
-
Save stuartpb/955912 to your computer and use it in GitHub Desktop.
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
--table of Windows Time Display Notation specifiers | |
--(http://support.microsoft.com/kb/307938) to the equivalent | |
--format specifiers for the Visual C++ Runtime Library's | |
--version of strftime (http://msdn.microsoft.com/en-us/library/fe06s4ak.aspx). | |
local wtdn2sftf = { | |
--'t' does only the first character of %p: | |
--no strftime equivalent | |
tt = 'p', | |
H = '#H', | |
h = '#I', | |
HH = 'H', | |
hh = 'I', | |
m = '#M', | |
mm = 'M', | |
s = '#S', | |
ss = 'S', | |
d = '#d', | |
dd = 'd', | |
ddd= 'a', | |
dddd='A', | |
M = '#m', | |
MM = 'm', | |
y = '#y', | |
yy = 'y', | |
yyy= '#Y', --undocumented | |
yyyy='Y', | |
} | |
local function wtdnftime(format, time) | |
format = format or "%c" | |
time = time or os.time() | |
return os.date(string.gsub(format, | |
"([thHmsdMy]*)",function(spec) | |
if wtdn2sftf[spec] then return '%'..wtdn2sftf[spec] | |
else return spec end | |
end),time) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment