Add playlist page and endpoint

This commit is contained in:
Omar Roth
2018-08-15 10:22:36 -05:00
parent fa2ba807a3
commit bb0b60e575
7 changed files with 311 additions and 59 deletions

View File

@@ -64,10 +64,23 @@ end
def decode_date(string : String)
# String matches 'YYYY'
if string.match(/\d{4}/)
if string.match(/^\d{4}/)
return Time.new(string.to_i, 1, 1)
end
# Try to parse as format Jul 10, 2000
begin
return Time.parse(string, "%b %-d, %Y", Time::Location.local)
rescue ex
end
case string
when "today"
return Time.now
when "yesterday"
return Time.now - 1.day
end
# String matches format "20 hours ago", "4 months ago"...
date = string.split(" ")[-3, 3]
delta = date[0].to_i