I would like to write some code which takes in a time and outputs the words of that time.
time <- c("5:00", "5:01", "5:10", "5:15", "5:30", "5:40", "5:45", "5:47", "5:28")
words <- c("five o`clock", "one minute past five",
"ten minutes past five", "quarter past five",
"half past five", "twenty minutes to six", "quarter to six",
"thirteen minutes to six", "twenty eight minutes past five")
df <- cbind(time, words)
df
That is for 1 <= 30
minutes use the word "past" and for 30 > "minutes"
use to.
I would like to print the time in words for any time format such as the following:
time words
[1,] "5:00" "five o`clock"
[2,] "5:01" "one minute past five"
[3,] "5:10" "ten minutes past five"
[4,] "5:15" "quarter past five"
[5,] "5:30" "half past five"
[6,] "5:40" "twenty minutes to six"
[7,] "5:45" "quarter to six"
[8,] "5:47" "thirteen minutes to six"
[9,] "5:28" "twenty eight minutes past five"