Skip to content

Instantly share code, notes, and snippets.

@zard1989
Created March 8, 2010 21:38
Show Gist options
  • Select an option

  • Save zard1989/325780 to your computer and use it in GitHub Desktop.

Select an option

Save zard1989/325780 to your computer and use it in GitHub Desktop.
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