Epoch seconds and the wallclock

Did you know that daylight savings was in affect on Jan 1st 1970?

Have you seen code that takes a zero seconds epoch offset and assumes that it represents a wallclock time of 00:00?

I know I have! Watch out for poor coding with times and dates: use a trusted library of date utilities e.g. Jakarta Commons Lang when using Java.

michael@fs1:~$ perl -e 'print scalar localtime(0)."\n"'
Thu Jan  1 01:00:00 1970

package com.tecspy.sched;

import java.sql.Timestamp;

public class TimestampBug {

    /**
    * @param args
    */
    public static void main(String[] args) {
        // Note that the Timestamp.toString uses the current locale which here
        // in the UK is GMT with adjustments for local daylight savings time
        // now zero milliseconds or 00:00 Jan 1st 1970 UTC (or GMT) was
        // actually 1am in local time since daylight savings was in effect at
        // that time!
        Timestamp t = new Timestamp(0);
        t.setTime(0);
        String s = t.toString();
        System.out.println(s);

    }

}

http://en.wikipedia.org/wiki/Unix_time
http://en.wikipedia.org/wiki/Epoch_(reference_date)
http://en.wikipedia.org/wiki/Coordinated_Universal_Time