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 [email protected] http://lists.gnu.org/mailman/listinfo/help-glpk
