Skip to content

Instantly share code, notes, and snippets.

@ferblape
Created June 18, 2010 18:17
Show Gist options
  • Save ferblape/444000 to your computer and use it in GitHub Desktop.
Save ferblape/444000 to your computer and use it in GitHub Desktop.
# Imaginad que hoy es 31 de mayo. ¿"1 month ago" tendría que ser 30 de abril o 1 de mayo?
# Rails: 30 de abril
>> t = Time.local 2010,05,31
=> lun may 31 00:00:00 -0400 2010
>> t - 1.month
=> vie abr 30 00:00:00 -0400 2010
>> t = Time.local 2010,05,30
=> dom may 30 00:00:00 -0400 2010
>> t - 1.month
=> vie abr 30 00:00:00 -0400 2010
# Chronic: 1 de mayo
>> require 'chronic'
>> Chronic.parse("1 month ago", :now => Time.local(2010,05,31))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment