Figure out month number from month abbrievation

Christos Georgiou tzot at sil-tec.gr
Wed Apr 12 16:58:00 EDT 2006


On 12 Apr 2006 13:20:28 -0700, rumours say that "Bill"
<foobarbazqux at ftml.net> might have written:

>Hello --
>I'm parsing the output of the finger command, and was wondering
>something...If I'm given a month abbrievation (such as "Jan"), what's
>the best way to figure out the month number?

Try

import time
help(time.strftime)

and then this *might* work for you:

month_as_string= "Jan"
time.strptime(month_as_string, "%b").tm_mon

"Localization" (as Fredrik also suggested) is the reason for the *might* in
my previous sentence.
-- 
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians



More information about the Python-list mailing list