Skip to content

Instantly share code, notes, and snippets.

@epequeno
Created February 18, 2013 17:05
Show Gist options
  • Save epequeno/4978886 to your computer and use it in GitHub Desktop.
Save epequeno/4978886 to your computer and use it in GitHub Desktop.
is_after() walkthrough 16.2
In [7]: t1 = mytime.Time(2013, 1, 1, 12)
In [8]: t1.date.ctime()
Out[8]: 'Tue Jan 1 12:00:00 2013'
In [9]: t2 = mytime.Time(2013, 1, 1, 1)
In [10]: t2.date.ctime()
Out[10]: 'Tue Jan 1 01:00:00 2013'
In [11]: mytime.is_after(t1, t2)
Out[11]: True
Here we can see that 12 is interpreted as 12PM and 1 is interpreted as 1AM, so is_after() reports that t1 is chronologically after t2 which is correct. If we put 12 to indicate midnight and 1 to indicate
In [16]: t3 = mytime.Time(2013, 1, 1, 0)
In [17]: t3.date.ctime()
Out[17]: 'Tue Jan 1 00:00:00 2013'
t3 is interpreted as 12am
In [18]: t4 = mytime.Time(2013, 1, 1, 13)
In [19]: t4.date.ctime()
Out[19]: 'Tue Jan 1 13:00:00 2013'
t4 is interpreted as 1pm
In [20]: mytime.is_after(t3, t4)
Out[20]: False
In this case t3 is earlier than t4 and is_after() reports that correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment