equal
deleted
inserted
replaced
1 def get_date_from_str(date_str): |
1 month2mm = { 'JAN': 1, 'FEB': 2, 'MAR': 3, 'APR': 4, 'MAY': 5, |
2 month2mm = { |
2 'JUN': 6, 'JUL': 7, 'AUG': 8, 'SEP': 9, 'OCT': 10, 'NOV': 11, |
3 'January': 1, |
3 'DEC': 12 } |
4 'February': 2, |
|
5 'March': 3, |
|
6 'April': 4, |
|
7 'May': 5, |
|
8 'June': 6, |
|
9 'July': 7, |
|
10 'August': 8, |
|
11 'September': 9, |
|
12 'October': 10, |
|
13 'November': 11, |
|
14 'December': 12, |
|
15 } |
|
16 |
4 |
17 dd, month, yyyy = date_str.split() |
5 COMMA = ',' |
|
6 SPACE = ' ' |
|
7 date_str = raw_input('Enter a date string? ') |
|
8 date_str = date_str.replace( COMMA, SPACE) |
|
9 d, m, y = date_str.split() |
|
10 dd = int( d ) |
|
11 mon = m[:3].upper() |
|
12 mm = month2mm[mon] |
|
13 yyyy = int( y ) |
18 |
14 |
19 mm = month2mm[month] |
15 print dd,mm, yyyy |
20 return int(yyyy), int(dd.strip(',')), mm |
|
21 |
|
22 date_str = raw_input('Enter a date string? ') |
|
23 print get_date_from_str(date_str) |
|