我想写一个时间格式化程序,time_format(hours, minutes)
它需要一天中的时间,以小时和分钟表示,四舍五入到最接近的 5 分钟,并用英文单词表示。
我需要编写一个格式化输入的方法,例如
"9,1"
进入“九点”
time_format(9, 1) returns "nine o'clock"
time_format(9, 5) returns "five after nine"
time_format(9, 13) returns "quarter after nine"
time_format(9, 9) returns "ten after nine"
time_format(9, 20) returns "twenty after nine"
time_format(9, 24) returns "twenty five after nine"
time_format(9, 30) returns "half past nine"
time_format(9, 36) returns "twenty five to ten"
time_format(9, 38) returns "twenty to ten"
time_format(9, 45) returns "quarter to ten"
time_format(9, 50) returns "ten to ten"
time_format(9, 56) returns "five to ten"
time_format(12, 00) returns "noon"
time_format(15, 20) returns "twenty after three"
time_format(23, 45) returns "a quarter to midnight"
知道我该怎么做吗?我一直在查看日期对象,但它没有给我提供像 20 这样的数字并获取它的文字文本的方法。