Python Day of Week

I was creating a plugin for Nagios which needed to define thresholds based on time of day and day of week. A lot of searching took me to one really nice function: localtime. You can use it as below.

from time import localtime

The output is something like this: (2010, 4, 22, 15, 35, 48, 3, 112, 1). This output contains data in the following order: year, month, day, hour, minute, second, day of week, day of year, and I don’t know what is the last column.

One Response to Python Day of Week

  1. John C says:

    The last value indicates daylight savings time. In your example above, 1 means DST is currently operating.

%d bloggers like this: