[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] Time conversion functions
From: |
glpk xypron |
Subject: |
Re: [Help-glpk] Time conversion functions |
Date: |
Wed, 26 Nov 2008 05:36:56 +0100 |
Hello Andrew,
>> It is *not* defined whether t is UTC, local time, or somewhat else.
If only function str2time() and time2str() exist this is valid.
>> but, in my opinion, using the daylight save time in modeling is an extremely
>> bad idea
You proposed to add a function time() to obtain the current time, which I
appreciate. When implementing it you have to decide in which time zone the
return value is.
My suggestion is that this function time() should return a value in UTC. This
can be achieved using C99 functions time() and gmtime(). (In your current
implementation you use localtime()).
If function time() were in local time it would have discontinuities due to day
light saving time, which as you stated should be avoided.
>> If in your model t is UTC, and
>> you need to convert it to a local time, you should add the time offset
>> which takes into account the timezone and daylight saving info and is
>> defined in your model.
If my data is relative to UTC the ISO 8601 time stamps may look like this
2008-11-26T05:00:00Z - Z indicating that the time zone is UTC or like this
2008-11-26T06:00:00+0001 - refering to the same time, +0001 indicating that the
time zone is UTC + 1 hour. (If data is in [unspecified] local time there will
be no Z and no offset.)
cf http://en.wikipedia.org/wiki/ISO_8601#Other_time_zones
If I have data in the ISO format with different offsets relative to UTC I would
like to be able parse the offset.
Parsing the offset in GMPL would be quite tedious.
Hence I suggest to add a format code '%z' to function str2time(). %z is used
for the same purpose in the C99 function strftime().
For output it is sufficient to add the offset manually:
printf "The following timestamps are equal:\n";
printf time2str(t, "%FT%TZ\n");
printf time2str(t+3600, "%FT%T+0100\n");
The following formats of offsets are allowed by ISO 8601:
Z
+hh
-hh
+hhmm
-hhmm
+hh:mm
-hh:mm
Best regards
Xypron
--
Sensationsangebot nur bis 30.11: GMX FreeDSL - Telefonanschluss + DSL
für nur 16,37 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a
- Re: [Help-glpk] Time conversion functions, (continued)
- Re: [Help-glpk] Time conversion functions, Andrew Makhorin, 2008/11/21
- Re: [Help-glpk] Time conversion functions, xypron, 2008/11/21
- Re: [Help-glpk] Time conversion functions, xypron, 2008/11/21
- Re: [Help-glpk] Time conversion functions, Andrew Makhorin, 2008/11/22
- Re: [Help-glpk] Time conversion functions, Xypron, 2008/11/22
- Re: [Help-glpk] Time conversion functions, Andrew Makhorin, 2008/11/22
- Re: [Help-glpk] Time conversion functions, Xypron, 2008/11/22
- Re: [Help-glpk] Time conversion functions, Andrew Makhorin, 2008/11/23
- Message not available
- Message not available
- Message not available
- Message not available
- Re: [Help-glpk] Time conversion functions, Xypron, 2008/11/24
- Re: [Help-glpk] Time conversion functions, Andrew Makhorin, 2008/11/25
- Re: [Help-glpk] Time conversion functions,
glpk xypron <=
Re: [Help-glpk] Time conversion functions, Andrew Makhorin, 2008/11/18
Re: [Help-glpk] Time conversion functions, Harley Mackenzie, 2008/11/18
Re: [Help-glpk] Time conversion functions, Nigel Galloway, 2008/11/19
Re: [Help-glpk] Time conversion functions, Andrew Makhorin, 2008/11/22