Created
September 9, 2012 21:38
-
-
Save takehiko/3687481 to your computer and use it in GitHub Desktop.
Print current time in various formats
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
function now() { | |
case ${1:-_} in | |
-h*|--h*) # now --help | |
echo usage: now '[date|httpdate|rfc2822|iso8601]' ;; | |
d*) # now date | |
LC_ALL=C date ;; | |
h*) # now httpdate | |
ruby -e 'require "time"; puts Time.now.httpdate' ;; | |
i*|x*) # now iso8601, now xmlschema | |
ruby -e 'require "time"; puts Time.now.iso8601'\(${2:-0}\) ;; | |
r*) # now rfc2822, now rfc822 | |
ruby -e 'require "time"; puts Time.now.rfc2822' ;; | |
*) # now | |
now d | |
now h | |
now i | |
now r ;; | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment