day1/exercise/datestring.py
author Christopher Burns <chris.d.burns@gmail.com>
Sun, 27 Jun 2010 22:05:22 -0500
branchscipy2010
changeset 425 5afcfce15e71
parent 386 a0bec380b44f
permissions -rw-r--r--
REF: Reformat some of the exercises so they're easier to read for the audience.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
425
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
     1
month2mm = {'JAN': 1, 
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
     2
            'FEB': 2, 
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
     3
            'MAR': 3, 
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
     4
            'APR': 4, 
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
     5
            'MAY': 5, 
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
     6
            'JUN': 6,
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
     7
            'JUL': 7, 
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
     8
            'AUG': 8, 
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
     9
            'SEP': 9, 
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
    10
            'OCT': 10, 
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
    11
            'NOV': 11, 
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
    12
            'DEC': 12 }
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
COMMA = ','
5dc6c3673f9d Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 64
diff changeset
    15
SPACE = ' '
5dc6c3673f9d Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 64
diff changeset
    16
date_str = raw_input('Enter a date string? ')
425
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
    17
date_str = date_str.replace(COMMA, SPACE)
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
    18
day, month, year = date_str.split()
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
    19
dd = int(day)
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
    20
mon = month[:3].upper()
354
5dc6c3673f9d Changes made during REC Chennai workshop.
Puneeth Chaganti <punchagan@fossee.in>
parents: 64
diff changeset
    21
mm = month2mm[mon]
425
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
    22
yyyy = int(year)
64
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    23
425
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 386
diff changeset
    24
print dd, mm, yyyy