Template talk:JULIANDAY.JULIAN

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Template:JULIANDAY.JULIAN(edit talk links history)

The formula used is in this template is :

  (((year * 12 + month + 57608.5 round 0) / 12 - 1.5 round 0) * 1461 / 4 - 0.5 round 0)  + ((            (month + 57608.5 round 0) mod 12 + 4) * 153 / 5 - 0.5 round 0)  + day + hour / 24 + minute / 1440 + second / 86400  - 32167.5  

The formulas allows using date elements that are out of normal range, for date computing (for example when adding or substracting any number of months, and it works even if these months span one or more leap years). You can also specify hours out of the normal range 0..23, minutes seconds out of 0..59. And days of month out of the normal month range (1..31), so you can also add or substract any number of days. It ignores leap seconds (the returned JD considers all days having 24 hours exactly).

I fear there is a bug[edit]

Isn't it correct that the Difference between Gregorian and Julian calendar dates was 10 days in 1582 (October 5 became October 15) and is 13 days in 2006?

  • {{JULIANDAY|1582|10|15}} = {{JULIANDAY.JULIAN|1582|10|05}} : 2299161 = 2299161
  • {{JULIANDAY|2006|01|14}} = {{JULIANDAY.JULIAN|2006|01|01}} : 2453750 = 2453750

From Gregorian calendar : ... when the new calendar was put in use, the error ... was corrected by a deletion of ten days. The last day of the Julian calendar was Thursday 4 October 1582 and this was followed by the first day of the Gregorian calendar, Friday 15 October 1582... --5ko 12:20, 19 July 2006 (UTC)Reply[reply]

There's no error. You are taking wrong assumptions because you are not comparing the same dates (not the same calendars)!
  • JULIANDAY.JULIAN computes the Julian day and takes as parameters the date elements from the proleptic Julian calendar, if it was in application at the indicated Julian date.
  • JULIANDAY (which should be more explicitly named "JULIANDAY.GREGORIAN", but I did not change its name for compatibility reasons) computes the Julian day too, but takes as parameters the date elements from the proleptic Gregorian calendar if it was in application at the indicated Gregorian date.
Some have deleted '(without asking and without keeping anything in the history log! Grrrrrr....) the corresponding reverse templates without wondering why they were different (and this WAS explained in the doc). These templates deleted without justification were:
  • JULIANDAY.JULIAN.YEAR (computing the year in the Julian calendar from a JD), different from JULIANDAY.YEAR which returns the Gregorian year.
  • JULIANDAY.JULIAN.MONTH(computing the month in the Julian calendar from a JD), different from JULIANDAY.YEAR which returns the Gregorian month.
  • JULIANDAY.JULIAN.DAY (computing the day in the Julian calendar from a JD), different from JULIANDAY.YEAR which returns the Gregorian day of month.
There templates were used for computing the religious events that are still used today and based on the Julian calendar.
So the shift from 10 days in 1582, to 13 days in 2006 is normal between the Julian calendar and the Gregorian calendar (see Gregorian_calendar#Difference between Gregorian and Julian calendar dates). The Julian calendar is STILL used for computing religious events today!
verdy_p 15:08, 8 November 2006 (UTC)Reply[reply]
I know it is correct 10 days in 1582 and 13 days in 2006, but I asked why when I set the same day in both calendars (with the 10 or 13 days difference in the date), I get a different Julian day number (2299161 in the first place and 2299160 in the second). --5ko 02:12, 27 November 2006 (UTC)Reply[reply]

Just checked with the PHP built-in functions:

<?php  echo    juliantojd ( 10, 5, 1582 ); // 2299161  echo gregoriantojd ( 10, 15, 1582 ); // 2299161    echo    juliantojd ( 1, 1, 2006 );// 2453750  echo gregoriantojd ( 1, 14, 2006 );// 2453750     

So, the correct template is probably Template:JULIANDAY, this one needs to be adjusted by adding 1. --5ko 12:29, 19 July 2006 (UTC)Reply[reply]

No, there's no error: PHP is wrong here when it adds 1 to the result (note that it takes as parameters the date elements from the Gregorian calendar only, if it was in application at the indicated Gregorian date), but it forgets to consider the time of day: a Julian day starts at midday, not at 00:00 as PHP incorrectly assumes!
For compatibility with those that don't specify the time of day, this template assumes that the missing time is 12:00:00, by taking 12 as the default value for the missing hour parameter.
Look at the examples to be convinced. And note that if you don't specify the time of day, the parameters consider the date being at midnight (which is one day before in the Julian calendar.) This version is correct as it takes the specified time: before midday, it's still the previous day in the Julian calendar, and at midday up to midnight, it's the next day in the Julian calendar.
Look at the provided examples to be convinced!
verdy_p 15:08, 8 November 2006 (UTC)Reply[reply]
I know that the Julian day beguins at 12:00, but both the Julian calendar day and the Gregorian calendar day beguin at the same time (0:00). I still don't understand why there is one day difference in the julian day, when I enter the exact same day (not "date") and exact same time on both calendars:
{{JULIANDAY|1582|10|15|0|0|0}} = {{JULIANDAY.JULIAN|1582|10|05|0|0|0}} gives 2299160.5 = 2299160.5
{{JULIANDAY|1582|10|15|15|20|30}} = {{JULIANDAY.JULIAN|1582|10|05|15|20|30}} gives 2299161.1392361 = 2299161.1392361 (after 12:00)
The moment 1582-10-15 at 0h 0min 0s on the Gregorian calendar is the same moment as 1582-05-15 at 0h 0min 0s on the Julian calendar. Why the function does not return the same Julian day? Thanks!! --5ko 02:12, 27 November 2006 (UTC)Reply[reply]
P.S. I looked at the examples
That is, not 13 days as you stated above, but 12 days difference, which still puzzles me. The Julian day for the same moment should be the same, regardles of the calendar in which this moment is expressed. --5ko 02:26, 27 November 2006 (UTC)Reply[reply]
OK This is corrected. There was effectively the JD returned from a Julian calendar date was too large by exactly 1 day (I have just changed the last constant in the formula, so now the results are OK). I had to modify a few examples that I had manually created by converting a Gregorian calendar date to Julian calendar date, because I had used a 12 days calendar difference in the XXth century for testing the epochs of the other JD's (RJD, NIST, NASA...), instead of 13 days (in fact I had made them so that the result do match the expected epoch, so the examples themselves were wrong even if they gave the correct result. Now they return the expected result but from a correct example).
I can explain why a 1 day offset occured: this was caused by the way we have to truncate integers in MediaWiki "#expr": we must add 0.5 before rounding it to an integer, but the final additive constant in the formula was in fact substractive and I added 0.5 to the final constant instead of substracting 0.5 to it.
There was no bug in the Template:JULIANDAY itself, so computing the Julian day from a Gregorian date was OK). Now the two JD values match together when using a Gregorian calendar date with Template:JULIANDAY or a Julian calendar date with Template:JULIANDAY.JULIAN.
And effectively, the epoch for the Julian day now starts effectively on a Junuary 1st in the Julian calender (and not January 2 as before).
The reverse computing from the JD to a Gregorian date was not affected by the change in Template:JULIANDAY.JULIAN.
But I feel quite angry that someone deleted the templates computing back the Julian date elements from a JD, thinking these were duplicate. I'll have to recreatr them because I can't even find them in the history log.
I can recreate them.
Thank you!! In the summer I was trying to use your functions (great job by the way!) for a simple to use calculator Old style <-> New style for the Bulgarian Wikipedia. As Bulgaria adopted the Gregorian calendar in 1916, there are a big number of dates in our recent history that must be presented in both calendars; I believe your functions will be usefull to do this. I spotted this error while testing, but was unable to understand and fix it myself, so, thanks again! --5ko 20:35, 27 November 2006 (UTC)Reply[reply]

This template doesn't work[edit]

There should be any proble because the template doesn't work. It gives this answer:

Expression error: Unrecognised punctuation character "{"

Japf (talk) 15:38, 14 February 2010 (UTC)Reply[reply]

Unverifiable assertion. This template works perfectly (and its doc page contains many examples demonstraing it).
If you see this, the only cause is that you have forgotten a mandatory parameter, or passed within one of the parameters an expression built from another template needing parameters that you have forgotten there).
This template only requires parameter 1 (year) and take default values for all others. But it does not check the validity of numbers if you pass any non empty parameter : it is assumed that you will pass any number, or any valid numeric expression. verdy_p (talk) 05:10, 16 October 2010 (UTC)Reply[reply]

Template-protected edit request on 9 July 2021[edit]

Please remove the interlanguage links

[[fr:Modèle:{{PAGENAME}}]]  [[su:CItakan:JULIANDAY.JULIAN]]

They are already linked in wikidata, hence are redundant. ಮಲ್ನಾಡಾಚ್ ಕೊಂಕ್ಣೊ (talk) 10:20, 9 July 2021 (UTC)Reply[reply]

 Done firefly ( t · c ) 12:22, 9 July 2021 (UTC)Reply[reply]