Inquisitor

UnixTime2HTTPDate

Sep 13th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.81 KB | None | 0 0
  1. @Echo Off
  2. SetLocal EnableDelayedExpansion
  3. :: Unix timestamp to HTTP date format (RFC 1123)
  4. :: Dependencies: sqlite
  5.  
  6. If "%~1"=="" (Echo USAGE: %~nx0 unix timestamp & Exit /B)
  7.  
  8. Set Day[]= 0:Sun, 1:Mon, 2:Tue, 3:Wed, 4:Thu, 5:Fri, 6:Sat
  9. Set Month[]= 01:Jan, 02:Feb, 03:Mar, 04:Apr, 05:May, 06:Jun, 07:Jul, 08:Aug, 09:Sep, 10:Oct, 11:Nov, 12:Dec
  10.  
  11. Set "DayName=" & Set "MonthName="
  12. For /F "eol= tokens=1-4 delims=\" %%A In ('Echo SELECT strftime^(^'%%w\%%d\%%m\%%Y %%H:%%M:%%S GMT^'^, %~1^, ^'unixepoch^'^)^;^|sqlite3') Do (
  13.     For %%Q In (%Day[]%) Do (For /F "tokens=1,2 delims=:" %%R In ("%%Q") Do (If "%%A"=="%%R" Set DayName=%%S))
  14.     For %%Q In (%Month[]%) Do (For /F "tokens=1,2 delims=:" %%R In ("%%Q") Do (If "%%C"=="%%R" Set MonthName=%%S))
  15.     <nul Set /P "Echo=!DayName!, %%B !MonthName! %%D"
  16. )
  17. EndLocal
  18. Exit /B
Advertisement
Add Comment
Please, Sign In to add comment