|  | 
|  | 1 | +import datetime | 
|  | 2 | + | 
|  | 3 | +today = datetime.date.today() | 
|  | 4 | +print(today) | 
|  | 5 | +print('ctime  :', today.ctime()) | 
|  | 6 | +tt = today.timetuple() | 
|  | 7 | +print('tuple  : tm_year  =', tt.tm_year) | 
|  | 8 | +print('         tm_mon   =', tt.tm_mon) | 
|  | 9 | +print('         tm_mday  =', tt.tm_mday) | 
|  | 10 | +print('         tm_hour  =', tt.tm_hour) | 
|  | 11 | +print('         tm_min   =', tt.tm_min) | 
|  | 12 | +print('         tm_sec   =', tt.tm_sec) | 
|  | 13 | +print('         tm_wday  =', tt.tm_wday) | 
|  | 14 | +print('         tm_yday  =', tt.tm_yday) | 
|  | 15 | +print('         tm_isdst =', tt.tm_isdst) | 
|  | 16 | +print('ordinal:', today.toordinal()) | 
|  | 17 | +print('Year   :', today.year) | 
|  | 18 | +print('Mon    :', today.month) | 
|  | 19 | +print('Day    :', today.day) | 
|  | 20 | + | 
|  | 21 | +d1 = datetime.date(2008, 3, 29) | 
|  | 22 | +print('d1:', d1.ctime()) | 
|  | 23 | + | 
|  | 24 | +d2 = d1.replace(year=2009) | 
|  | 25 | +print('d2:', d2.ctime()) | 
|  | 26 | + | 
|  | 27 | +today = datetime.date.today() | 
|  | 28 | +print('Today    :', today) | 
|  | 29 | + | 
|  | 30 | +one_day = datetime.timedelta(days=1) | 
|  | 31 | +print('One day  :', one_day) | 
|  | 32 | + | 
|  | 33 | +yesterday = today - one_day | 
|  | 34 | +print('Yesterday:', yesterday) | 
|  | 35 | + | 
|  | 36 | +tomorrow = today + one_day | 
|  | 37 | +print('Tomorrow :', tomorrow) | 
|  | 38 | + | 
|  | 39 | +print() | 
|  | 40 | +print('tomorrow - yesterday:', tomorrow - yesterday) | 
|  | 41 | +print('yesterday - tomorrow:', yesterday - tomorrow) | 
0 commit comments