SubWCRev Generates Wrong Times

We want to run SubWCRev as an automated step in our process so we have the latest SVN metadata included in our executable. This makes it easier to identify executables as the file properties can include information about SVN revision numbers, build times, etc…


// these refer to the last commit date of this subtree
#define        SVN_DATE        "$WCDATE$"
#define        SVN_DATE_UTC    "$WCDATEUTC$"

// this is the compilation time
#define        SVN_NOW            "$WCNOW$"
#define        SVN_NOW_UTC        "$WCNOWUTC$"

However, if we automatically trigger the build with Cygwin, we can end up generating the wrong timestamps:


// these refer to the last commit date of this subtree
#define        SVN_DATE        "2016/06/07 00:11:16"
#define        SVN_DATE_UTC    "2016/06/06 23:11:16"

// this is the compilation time
#define        SVN_NOW            "2016/06/08 17:45:40"
#define        SVN_NOW_UTC        "2016/06/08 16:45:40"

This appears to be working fine for a GMT+1 time zone, except we’re on the other side of the world:


$ date
Wed, Jun  8, 2016 10:48:09

$ echo $TZ
America/Denver

This happens as a result of a conflict between Cygwin assuming the default city for a Windows time zone when calling native applications. We can fix this by unsetting the TZ environment variable:


$ unset TZ

Resulting in the correct time information:


// these refer to the last commit date of this subtree
#define        SVN_DATE        "2016/06/06 17:11:16"
#define        SVN_DATE_UTC    "2016/06/06 23:11:16"

// this is the compilation time
#define        SVN_NOW            "2016/06/08 10:49:16"
#define        SVN_NOW_UTC        "2016/06/08 16:49:16"

Leave a Reply

Your email address will not be published. Required fields are marked *

*