> convert "01/03/1937" to dateitems > I got invalid date ;( > > Maybe we should switch to stardate ;)) I can't offer Stardate to you, but Julian dates handle the number of days since noon 4713 BC January 1. These were posted by [EMAIL PROTECTED] (mailto:[EMAIL PROTECTED]) on 16 Apr 2004 and may provide you with the tools... At least they avoid the 'invalid date' syndrome!
/* date.julian return the julian count, i.e. days since 24.11.-4713 @param d is the day @param m is the month @param y is the year @returns is the julian count */ function date.julian d,m,y return (1461*(y+4800+(m-14) div 12)) div 4+(367*(m-2-12*((m-14) div 12))) div 12-(3*((y+4900.0+(m-14) div 12) div 100)) div 4+d-32075 end date.julian Example: answer date.julian 13,11,2001 /* get date.julian2DayOfWeek(aJulian) @purpose Returns the day of the week according to: 1..7 for Sunday..Saturday @param aJulian is the julian number. */ function date.julian2DayOfWeek aJulian -- // returns 1..7 for Sunday..Saturday return (aJulian+1) mod 7 + 1 end date.julian2DayOfWeek Example: answer date.julian2DayOfWeek 2452227 /* date.julian2DMY aJulian,@d,@m,@y @purpose Set the day, month year according to the julian date aJulian. */ on date.julian2DMY aJulian,@d,@m,@y put aJulian + 68569.0 into l put ( 4 * l ) div 146097.0 into n put l - ( 146097.0 * n + 3 ) div 4 into l put ( 4000.0 * ( l + 1 ) ) div 1461001.0 into i -- (that's 1,461,001) put l - ( 1461 * i ) div 4 + 31 into l put ( 80 * l ) div 2447.0 into j put l - ( 2447.0 * j ) div 80 into d -- day put j div 11 into l put j + 2 - ( 12 * l ) into m -- month put 100 * ( n - 49 ) + i + l into y -- year end date.julian2DMY Example: date.julian2DMY 2452227,d,m,y answer d,m,y /H Hugh Senior The Flexible Learning Company Web: _www.FlexibleLearning.com_ (http://www.flexiblelearning.com/) E: [EMAIL PROTECTED] (mailto:[EMAIL PROTECTED]) T/F: +44(0)1483.27 87 27 _______________________________________________ use-revolution mailing list [email protected] http://lists.runrev.com/mailman/listinfo/use-revolution
