Skip to content

Commit

Permalink
first working draft
Browse files Browse the repository at this point in the history
  • Loading branch information
epequeno committed Feb 5, 2013
1 parent 9def08f commit 262d463
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions ch16/16.02.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@
# t1 and t2, and returns True if t1 follows t2 chronologically and False
# otherwise. Challenge: don't use an if statement.

# Current Satus: Incomplete
# Current Satus: Complete

import datetime

class Time(object):
"""Time object based on datetime.datetime describes time in 24hr format"""
def __init__(self, year=2000, month=1, day=1, hour=12, minute=0, sec=0):
self.date = datetime.datetime(year, month, day, hour, minute, sec)


def time_to_int(self):
return int(self.date.strftime("%s"))

# 1 AM on Jan 1, 2001
t1 = Time(2001, 1, 1, 1)

# 12 AM on Jan 1, 2001
t2 = Time(2001, 1, 1, 0)


def is_after(time1, time2):
return time1.time_to_int() > time2.time_to_int()

print is_after(t2, t1)

0 comments on commit 262d463

Please sign in to comment.