Created
March 8, 2010 21:38
-
-
Save zard1989/325780 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def chinese_time(time=Time.now) | |
| chinese_hour = "子丑寅卯辰巳午未申酉戊亥".split(//u) | |
| chinese_num = "零壹貳參肆伍陸柒捌玖".split(//u) | |
| if time.hour.even? | |
| hour = time.hour | |
| min = time.min+60 | |
| else | |
| hour = time.hour+1 | |
| min = time.min | |
| end | |
| chinese_hour[(hour%24)/2] + "時" + chinese_num[min/15] + "刻" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment