in reply to timelocal problems

You're hitting the "duplicated" hour in the DST -> normal conversion. In my locale (MET) I had to set the time to 02:00 to get the error, and use localtime() instead of gmtime() that daveorg used in his example.

The duplicated hour in local time during the switch back to "normal" time (from DST) makes the conversion to UTC ambiguous during that period (once a year.)

If you need to avoid that issue you should probably store all dates and times in UTC, and only convert to localtime on display...

Michael