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