help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Help-glpk] Time conversion functions


From: Meketon, Marc
Subject: RE: [Help-glpk] Time conversion functions
Date: Tue, 18 Nov 2008 05:32:09 -0500

Xypron,

I use GMPL for time-space network modeling a lot.

Two common functions that I use are (pseudo code below) that would be
nice to add to your time library are:

    // change minutes to hour-minutes for display purposes
    mmm2hhmm(int mmm) { return mmm + 40*int(mmm/60); }

    //change hhmm form to minutes
    hhmm2mmm(int hhmm) { return hhmm - 40*int(hhmm/100); }

For example, 60 minutes becomes 0100 using mmm2hhmm(60), and 0100
becomes 60 minutes using hhmm2mmm(100)

-Marc

-----Original Message-----
From: address@hidden
[mailto:address@hidden On
Behalf Of xypron
Sent: Monday, November 17, 2008 5:51 PM
To: address@hidden
Subject: [Help-glpk] Time conversion functions


Hello Andrew,

currently I am using GLPK mainly for scheduling problems. Here the data
often contains references to time. The GMPL language does not provide
any
functions to convert timestamps to numbers and numbers back to
timestamps.

I propose to add the following functions:

now() returns the number of seconds since 1970
Knowing the current time is useful as scheduling should not place
production
in the past.

str2time( str, fmt ) converts a timestamp str given in format fmt to
number
of seconds since 1970
e.g. str2time( "2008-11-15T13:22:10+0300", "%Y-%m-%dT%H:%M:%S%z");
The time formats of RFC 3339 should be supported (a subset of ISO 8601).
The format strings should be a subset of those used by the strptime()
function in library GLIBC.
Conversion of non local time will have to rely on availability of either
function timegm() (or _mkgmtime for Microsoft Visual C) or structure
element
tm->tm_gmtoff.

localtime( num, fmt ) converts a number to a timestamp in local time
e.g. localtime( now(), "%Y-%m-%dT%H:%M:%S%")
a possible output would be 
2008-11-15T17:22:10
The format strings should be those used by the strftime() function in
C99.

gmtime( num, fmt ) converts a number to a timestamp in global time
e.g. gmtime( now(), "%Y-%m-%dT%H:%M:%S%Z")
a possibel output would be
2008-11-15T16:22:10
The format strings should be those used by the strftime() function in
C99.

I have implemented the necessary changes to glpk-4.33 which can be found
at 
http://glpk.dyndns.org/viewvc/svn/glpk/glpk/branches/glpk-4.33-strdate/
http://glpk.dyndns.org/viewvc/svn/glpk/glpk/branches/glpk-4.33-strdate/ 

new files are:
include/glptime.h
src/glptime.c

changed files are:
configure.ac
config.h.in
include/glpmpl.h
src/Makefile.am
src/glpmpl01.c
src/glpmpl03.c
w32/Makefile*
w32/config_VC9
w64/Makefile*
w64/config_VC9

Best regards

Xypron

-- 
View this message in context:
http://www.nabble.com/Time-conversion-functions-tp20549985p20549985.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.



_______________________________________________
Help-glpk mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-glpk
---------------------------------------------------------------------------- 
This e-mail and any attachments may be confidential or legally privileged.  If 
you received this message in error or are not the intended recipient, you 
should destroy the e-mail message and any attachments or copies, and you are 
prohibited from retaining, distributing, disclosing or using any information 
contained herein.  Please inform us of the erroneous delivery by return e-mail. 

Thank you for your cooperation.
---------------------------------------------------------------------------- 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]