Template talk:Ordinal date

message: :These issues are resolved
=== Expression replacement possibility ===

*
:Does MediaWiki support switch? --Uncle Ed 15:50, 19 April 2006 (UTC)
replies: text: Yes, see above.  This code can also be used with noinclude subst magic to timestamp the ordinal. — xaosflux Talk 02:33, 20 April 2006 (UTC)
replies: text: Implemented, please report any problems. — xaosflux Talk 23:30, 23 April 2006 (UTC)

text: The algorithm is wellknown. It uses a single formula based on the 153 days cycle every 5 months. The apparent computing complex is not an issue, but using an external template has a severe cost on the server. My formula is proven for the Gregorian calendar, and part of many libraries. verdy_p 18:15, 8 November 2006 (UTC)
thread_title:  Old discussions 

message: 
*
:Does MediaWiki support switch? --Uncle Ed 15:50, 19 April 2006 (UTC)
replies: text: Yes, see above.  This code can also be used with noinclude subst magic to timestamp the ordinal. — xaosflux Talk 02:33, 20 April 2006 (UTC)
replies: text: Implemented, please report any problems. — xaosflux Talk 23:30, 23 April 2006 (UTC)
thread_title:  Expression replacement possibility 

message: The day after February 29, 2008 this template will have a one off error. Perhaps we could fix this now, by incorporating a template like . --Uncle Ed 14:58, 27 April 2006 (UTC)
thread_title: Leap year

message: I've replaced the  code with  as it involves less computations. — xaosflux Talk 17:51, 29 April 2006 (UTC)
thread_title:  Code shrinking 

message: Old version: 

Updated version:

These both produce the same results right now:
=
I may be missing something, but the new version seems to be performing many more server side calculations everytime this template is invoked.  Also what is the base algorithim that is being used here?  And does it account for leap years?  The old version worked on the premise that the number of days per month is a static value, and offset leapyears with a test. — xaosflux Talk 00:46, 27 May 2006 (UTC)
replies: text: The algorithm is wellknown. It uses a single formula based on the 153 days cycle every 5 months. The apparent computing complex is not an issue, but using an external template has a severe cost on the server. My formula is proven for the Gregorian calendar, and part of many libraries. verdy_p 18:15, 8 November 2006 (UTC)
thread_title:  rv new code base 

message: 
Using the single formula, it works with subst, and does not use costly sub-templates (remember: subtempaltes are MORE costly for the server than #expr formulas which are very fast:
{{#expr:
 (((({{{year|{{CURRENTYEAR}}}}})*12+({{{month|{{CURRENTMONTH}}}}})+57608.5 round 0)/12-1.5 round 0)*1461/4-0.5 round 0)
-(((({{{year|{{CURRENTYEAR}}}}})*12+57609.5 round 0)/12-1.5 round 0)*1461/4-0.5 round 0)
-(((({{{year|{{CURRENTYEAR}}}}})*12+({{{month|{{CURRENTMONTH}}}}})+57608.5 round 0)/12-1.5 round 0)/100-0.5 round 0)
+(((({{{year|{{CURRENTYEAR}}}}})*12+57609.5 round 0)/12-1.5 round 0)/100-0.5 round 0)
+(((({{{year|{{CURRENTYEAR}}}}})*12+({{{month|{{CURRENTMONTH}}}}})+57608.5 round 0)/12-1.5 round 0)/400-0.5 round 0)
-(((({{{year|{{CURRENTYEAR}}}}})*12+57609.5 round 0)/12-1.5 round 0)/400-0.5 round 0)
+(((({{{month|{{CURRENTMONTH}}}}})+57608.5 round 0)mod 12+4)*153/5-0.5 round 0)
-428
+({{{day|{{CURRENTDAY}}}}})
}}
Result after subst: 
: And look above: it works with BC years too, starting on January 1, 4801 BC (i.e. -4800 using the proleptic Gregorian calendar, with astronomical year numbering)!
: And note that it's not because you don't understand a modular arithmetic formula that it is wrong. The formula is exact and proven according to the astronomical definitions of the Gregorian calendar. The principles in this formula is to compute dates based on years starting in March; years are in a 1461 days cycle every 4 years; months are computed according to the 153 days cycle every 5 months. For more information about how it works, look at Julian day. (For higher precision, including far years, the formula is now based on the most recent and precise formula in Template:JULIANDAY.
: The formula is directly equivalent to -, and slightly optimized where there are constants and terms of the difference are arranged by type.
: Note also that the 0.5 adjustments in the formula are only needed for correct truncation of integers usign the round operator (because of its mathematical limitations for cyclic moular arithmetic). Unfortunately, there's no #expr operator that supports the true modulo and div operators for modular artithmetic (which is the arithmetic system used in all calendar and astronomical cyclic calculations).
verdy_p 18:38, 8 November 2006 (UTC)
thread_title:  testing