[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] Time conversion functions
From: |
Nigel Galloway |
Subject: |
Re: [Help-glpk] Time conversion functions |
Date: |
Wed, 19 Nov 2008 13:42:11 +0100 |
Interestingly God's plan for man to arrange his time revealed through the head
of his church on earth Gregory is such that it repeats every 400 years. The
100s not being a leap year unless they are a 400. This being the revealed word
of God, spoken by Gregory, I would consider it blasphomous to prove it and
certainly I am not going to attempt to disprove it. I accept it on faith that
Spring arriving at Christmas is due to mans warming activity and not a fault in
the Calander.
It follows that in every 400 year period there are (24*3 + 25) February 29ths,
each in the sequence falling on the same day each 400 years. 97 does not divide
by 7 therefore each day Monday through Sunday can not be February 29th equally.
Every other date occurs 400 times, which also does not divide by 7.
Therefore we must conlude that it is not part of God's plan that each date is
equally represented by day.
It is possible though to put a Julian date within a 400 year period and then
calculate the date without the 1 to 4000 or any other restriction.
> ----- Original Message -----
> From: "Andrew Makhorin" <address@hidden>
> To: xypron <address@hidden>
> Cc: address@hidden
> Subject: Re: [Help-glpk] Time conversion functions
> Date: Wed, 19 Nov 2008 00:13:29 +0300
>
>
> > 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.
>
> Just an example that demonstrates another way to implement date/time in
> MathProg without any changes in the translator.
>
> The model below implements the Gregorian calendar. Parameter jday
> converts the plain date to the Julian day, and parameters year, month,
> and day converts the julian day to the corresponding date components.
> Though the model is a bit intricated, it works correctly for all dates
> in the range from 0001/01/01 to 4000/12/31.
>
>
> /* date.mod */
>
> param jday{y in 1..4000, m in 1..12, d in 1..31}, integer, :=
> (146097 * ((y - (if m <= 2 then 1)) div 100)) div 4 +
> (1461 * ((y - (if m <= 2 then 1)) mod 100)) div 4 +
> (153 * (m + (if m <= 2 then 9 else -3)) + 2) div 5 + d + 1721119;
>
> param jdate{f in 0..10, j in 1721426..3182395}, integer, :=
> if f = 0 then
> j - 1721119
> else if f = 1 then
> (4 * jdate[0,j] - 1) div 146097
> else if f = 2 then
> (4 * jdate[0,j] - 1) mod 146097
> else if f = 3 then
> jdate[2,j] div 4
> else if f = 4 then
> (4 * jdate[3,j] + 3) div 1461
> else if f = 5 then
> (4 * jdate[3,j] + 3) mod 1461
> else if f = 6 then
> (jdate[5,j] + 4) div 4
> else if f = 7 then
> (5 * jdate[6,j] - 3) div 153
> else if f = 8 then
> (5 * jdate[6,j] - 3) mod 153
> else if f = 9 then
> (jdate[8,j] + 5) div 5
> else /* f = 10 */
> 100 * jdate[1,j] + jdate[4,j];
>
> param year{j in 1721426..3182395}, integer, :=
> jdate[10,j] + (if jdate[7,j] <= 9 then 0 else 1);
>
> param month{j in 1721426..3182395}, integer, :=
> jdate[7,j] + (if jdate[7,j] <= 9 then +3 else -9);
>
> param day{j in 1721426..3182395}, integer, :=
> jdate[9,j];
>
> /**********************************************************************/
>
> param YEAR := 2008;
>
> param beg := jday[YEAR,1,1];
>
> param end := jday[YEAR,12,31];
>
> printf{j in beg..end} "j = %d; day = %02d month = %02d year = %04d\n",
> j, day[j], month[j], year[j];
>
> end;
>
>
>
> _______________________________________________
> Help-glpk mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-glpk
>
--
_______________________________________________
Surf the Web in a faster, safer and easier way:
Download Opera 9 at http://www.opera.com
Powered by Outblaze
- Re: [Help-glpk] Time conversion functions, (continued)
- 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, 2008/11/25
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 <=
Re: [Help-glpk] Time conversion functions, Andrew Makhorin, 2008/11/22