Last active
May 28, 2016 13:39
-
-
Save sharkpp/7f45f212b1d58609bf7ee19164630452 to your computer and use it in GitHub Desktop.
http://www.sharkpp.net/blog/2016/05/28/compare-format-for-date-to-string-php-and-ruby.html 用のスクリプト(Ruby Time:strftime)
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
# The MIT License (MIT) | |
# Copyright (c) 2016 sharkpp. | |
# See: https://opensource.org/licenses/mit-license.php | |
t = Time.at(ARGV[0].to_i); | |
# http://docs.ruby-lang.org/ja/2.2.0/method/Time/i/strftime.html | |
[ | |
'%A', | |
'%a', | |
'%B', | |
'%b', | |
'%C', | |
'%c', | |
'%D', | |
'%d', | |
'%e', | |
'%F', | |
'%H', | |
'%h', | |
'%I', | |
'%j', | |
'%k', | |
'%L', | |
'%l', | |
'%M', | |
'%m', | |
'%n', | |
'%N', | |
'%6N', | |
'%3N', | |
'%P', | |
'%p', | |
'%R', | |
'%r', | |
'%S', | |
'%s', | |
'%T', | |
'%t', | |
'%U', | |
'%u', | |
'%v', | |
'%V', | |
'%W', | |
'%w', | |
'%X', | |
'%x', | |
'%Y', | |
'%y', | |
'%Z', | |
'%z', | |
'%:z', | |
'%::z', | |
'%%', | |
# ほかの言語と同様に出力できるフォーマット | |
'%-e', | |
'%-m', | |
'%-H', | |
'%-l', | |
'%FT%T%:z', | |
'%a, %d %b %Y %T %z', | |
'%#P', | |
].each { | |
|fmt| | |
print fmt + '@@' + t.strftime(fmt) + '@~'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment