day1/exercise/datestring.py
author Puneeth Chaganti <punchagan@fossee.in>
Tue, 12 Jan 2010 19:03:34 +0530
changeset 354 5dc6c3673f9d
parent 64 333092b68926
child 386 a0bec380b44f
permissions -rw-r--r--
Changes made during REC Chennai workshop.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
354
5dc6c3673f9d Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 64
diff changeset
     1
month2mm = { 'JAN': 1, 'FEB': 2, 'MAR': 3, 'APR': 4, 'MAY': 5,
5dc6c3673f9d Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 64
diff changeset
     2
'JUN': 6, 'JUL': 7, 'AUG': 8, 'SEP': 9, 'OCT': 10, 'NOV': 11,
5dc6c3673f9d Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 64
diff changeset
     3
'DEC': 12 }
64
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     4
354
5dc6c3673f9d Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 64
diff changeset
     5
COMMA = ','
5dc6c3673f9d Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 64
diff changeset
     6
SPACE = ' '
5dc6c3673f9d Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 64
diff changeset
     7
date_str = raw_input('Enter a date string? ')
5dc6c3673f9d Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 64
diff changeset
     8
date_str = date_str.replace( COMMA, SPACE)
5dc6c3673f9d Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 64
diff changeset
     9
d, m, y = date_str.split()
5dc6c3673f9d Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 64
diff changeset
    10
dd = int( d )
5dc6c3673f9d Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 64
diff changeset
    11
mon = m[:3].upper()
5dc6c3673f9d Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 64
diff changeset
    12
mm = month2mm[mon]
5dc6c3673f9d Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 64
diff changeset
    13
yyyy = int( y )
64
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    14
354
5dc6c3673f9d Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 64
diff changeset
    15
print dd,mm, yyyy