|
From: Ethan M. <merritt@u.washington.edu> - 2007-08-08 00:42:46
|
gp_time.h contains the following definitions: /* defines used for timeseries, seconds */ #define ZERO_YEAR 2000 #define JAN_FIRST_WDAY 6 /* 1st jan, 2000 is a Saturday (cal 1 2000 on unix) */ #define SEC_OFFS_SYS 946684800.0 /* zero gnuplot (2000) - zero system (1970) */ #define YEAR_SEC 31557600.0 /* avg, incl. leap year */ #define MON_SEC 2629800.0 /* YEAR_SEC / 12 */ #define WEEK_SEC 604800.0 #define DAY_SEC 86400.0 The problem is, these values are not correct so far as I can determine. The actual mean number of seconds per year according to the Time Service Dept of the U.S. Naval Observatory is 31556926.0 This causes gnuplot's conversion from base year 1970 to 2000 to be off by about 20220 seconds, which is about 5 1/2 hours. A symptom of this is that if you read in time data using the "%s" timefmt, the time you get is wrong by 5 hours. Is there any reason we should tolerate this level of error? It seems very strange that anyone would have gone to the trouble of working out the zero point offsets, but failed to notice a 5 hour error. Am I missing something here? -- Ethan A Merritt |
|
From: <HBB...@t-...> - 2007-08-08 09:53:06
|
Ethan Merritt wrote: > /* defines used for timeseries, seconds */ > #define ZERO_YEAR 2000 > #define JAN_FIRST_WDAY 6 /* 1st jan, 2000 is a Saturday (cal 1 2000 on unix) */ > #define SEC_OFFS_SYS 946684800.0 /* zero gnuplot (2000) - zero system (1970) */ > #define YEAR_SEC 31557600.0 /* avg, incl. leap year */ > #define MON_SEC 2629800.0 /* YEAR_SEC / 12 */ > #define WEEK_SEC 604800.0 > #define DAY_SEC 86400.0 > The problem is, these values are not correct so far as I can determine. You determined incorrectly. > The actual mean number of seconds per year according to the > Time Service Dept of the U.S. Naval Observatory is 31556926.0 That's the mean number of seconds of the actual astronomical year. But we're dealing with calendars here, not with astronomy. The average length of a calender year, in the period under consideration (1970 to roughly 2038), is 365.25 days. Multiply that by DAY_SEC and you get exactly those 31557600 seconds found in our YEAR_SEC. > This causes gnuplot's conversion from base year 1970 to 2000 to be > off by about 20220 seconds, which is about 5 1/2 hours. We're not, as can be shown rather easily by looking at the relevant reference tool's output: $ date --date='2000-01-01 00:00:00 UTC' +'%s' 946684800 > A symptom of this is that if you read in time data using the "%s" > timefmt, the time you get is wrong by 5 hours. I'm close to 100% certain that this is not the reason. Time zones are way more probable to cause that. |
|
From: <pl...@pi...> - 2007-08-08 11:27:01
|
On Wed, 08 Aug 2007 11:52:33 +0200, Hans-Bernhard Bröker <HBB...@t-...> wrote: > That's the mean number of seconds of the actual astronomical year. But > we're dealing with calendars here, not with astronomy. The average > length of a calender year, in the period under consideration (1970 to > roughly 2038), is 365.25 days. Multiply that by DAY_SEC and you get > exactly those 31557600 seconds found in our YEAR_SEC. That's the average over a period with exactly 3 non leap years and one leap year. This will not be the average of any arbitary period within the range you indicate. What is required is the actual number of leap and non leap years an thier actual number of days 365/366, not an average ( I presume you are in fact refering to the mean rather than "average" which has several definitions). Applying an average here is like expecting the family next door to have 2.4 children. ;) |
|
From: <pl...@pi...> - 2007-08-08 11:48:20
|
On Wed, 08 Aug 2007 11:52:33 +0200, Hans-Bernhard Bröker <HBB...@t-...> wrote: >> The problem is, these values are not correct so far as I can determine. > You determined incorrectly. You also. There are 7 leap years from 1.1.1970 to 1.1.2000 and 23 non leaps. So the application of your simplistic average is wrong. If you want to work with a mean year length in days it is 365.233333333 that is a difference of precisely four hours from the current value in gnuplot. Since all this is UTC I suggest you look at daylight saving as a possible reason for the other hour of discrepancy. regards, Peter. |
|
From: Ethan A M. <merritt@u.washington.edu> - 2007-08-08 15:32:03
|
On Wednesday 08 August 2007 02:52, Hans-Bernhard Br=F6ker wrote:
> > This causes gnuplot's conversion from base year 1970 to 2000 to be
> > off by about 20220 seconds, which is about 5 1/2 =A0hours.
>=20
> We're not, as can be shown rather easily by looking at the relevant=20
> reference tool's output:
>=20
> $ date --date=3D'2000-01-01 00:00:00 UTC' +'%s'
> 946684800
Yes, but the code that is actually being used in time.c is this:
/* offset from UNIX epoch (1970) to gnuplot epoch */
static const long epoch_offset
=3D (long)((ZERO_YEAR - 1970) * 365.25) * DAY_SEC;
and ((ZERO_YEAR - 1970) * 365.25) * DAY_SEC
=3D (2000-1970) * 365.25 * 86400.0
=3D 946728000.0
which is not the same number.
=2D-=20
Ethan A Merritt
Biomolecular Structure Center
University of Washington, Seattle 98195-7742
|