473,804 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calendar fun

The Julian Calendar, adopted in 46BC by Julius Caesar, adds one day every
four years to correct for the fact that Earth's solar year is slightly more
than 365 of Earth's daily rotations. ( 365.25 days per year)

The Gregorian Calendar, adopted in 1582 by Pope Gregory XIII, ordered that
leap years should not occur in years ending in '00', unless divisible by
400. ( 365.2475 days per year)

A modern estimate of a calendar year is 365.24219 rotations of Earth per
solar year.
Calendar days since 46BC
46BC = 366
(( 2004 + 46) * 365) = 748250
(( 2004 + 46) / 4) = 512
( 1600, 2000) = -2
= 749126

Actual days since 46BC
( 2004 + 47) * 365.24219
= 749111.73169

Accumulated error
= 14.26831

Using the Gregorian Calendar accumulates about 5 Earth rotational day error
for every thousand solar years.

An even more modern calendar error correction rule can be stated as,
add one day every four years, using February 29th, unless the year is
exactly divisible by 128. ( 365.2421875) This may accumulate 1 Earth
rotational day error for every hundred thousand solar years.
Jul 17 '05 #1
4 2559
Excatly which years, or even whether 46BC was a leap year,
is not certain according to historians.

http://www.tondering.dk/claus/calendar.html

maw
Jul 17 '05 #2
/*

program: leap1
description: test for leap year accuracy, adjusts for Earth's rotational rate,
assumed to be constantly decreasing.

Gregorian calendar method is more accurate thru year 100,000
Whereas, a modulo 128 method accumulates 31 days of error in 100,000 years.

maw
makerun leap1 50000 100000

adding: leap1.class (in=1663) (out=938) (deflated 43%)
Year = 50000
Days Float0 = 1.8262178498500 004E7
Days Float1 = 1.8262178353000 224E7
Days Gregorian = 18262125
Days intDays1 = 18262110
Year = 100000
Days Float0 = 3.6524506997000 01E7
Days Float1 = 3.6524506705998 56E7
Days Gregorian = 36524250
Days intDays1 = 36524219

*/
import java.io.*;

public class leap1
{
static double earthRotationsP erYear0 = 365.24207;
static double earthRotationsY earIncrement = 0.00000006;
static double earthRotations1 00YearIncrement = 0.000006;
private static void leapTest( long yearModulo, long yearStop) {
long intDays0 = 0;
long intDays1 = 0;
double floatDays0 = 0.0;
double floatDays1 = 0.0;
double floatDays1PerYe arIncrement = earthRotationsP erYear0;

for( long i=0; i<yearStop; i++) {

floatDays0 += earthRotationsP erYear0 + (i * earthRotationsY earIncrement);

if ((( i+1) % 100) == 0)
floatDays1PerYe arIncrement += earthRotations1 00YearIncrement ;
floatDays1 += floatDays1PerYe arIncrement;

intDays0 += 365;
if ((( i+1) % 4) == 0) {
if ((( i+1) % 100) != 0)
intDays0++;
else if ((( i+1) % 400) == 0)
intDays0++;
}

intDays1 += 365;
if ( ((( i+1) % 4) == 0) &&
((( i+1) % 128) != 0) )
intDays1++;

if ((( i+1) % yearModulo) == 0) {
System.out.prin tln( " Year = " + (i+1) );
System.out.prin tln( " Days Float0 = " + floatDays0 );
System.out.prin tln( " Days Float1 = " + floatDays1 );
System.out.prin tln( " Days Gregorian = " + intDays0 );
System.out.prin tln( " Days intDays1 = " + intDays1 );

}
} // end for
} // end leapTest

public static void main(String[] args) {
if (args.length != 2) {
System.err.prin tln("Usage: java leap1 " +
"<year modulo> <year end>");
}
else {
try {
leapTest( Long.parseLong( args[0], 10), Long.parseLong( args[1], 10) );
} catch (Exception e) {
System.err.prin tln(
"Exception Error:" + e.getMessage()) ;
}
}
}

} // End of public class leap1
Jul 17 '05 #3
/*

program: leap2
date: Monday, March 1st, 2004
description: test for leap year accuracy, adjusts for Earth's rotational rate,
assumed to be constantly decreasing.

for leap year skip calculation, mod 128 is more accurate than Gregorian method

maw
makerun leap2 5000 15000

adding: leap2.class (in=1665) (out=937) (deflated 43%)
Year = 5000
Days Float0 = 1826210.8001499 996
Days Float1 = 1826210.8147000 133
Days Gregorian = 1826212
Days intDays1 = 1826211
Year = 10000
Days Float0 = 3652420.1002999 996
Days Float1 = 3652420.1293999 623
Days Gregorian = 3652425
Days intDays1 = 3652422
Year = 15000
Days Float0 = 5478627.90045
Days Float1 = 5478627.9441000 51
Days Gregorian = 5478637
Days intDays1 = 5478633

*/

import java.io.*;

public class leap2
{
static double earthRotationsP erYear0 = 365.24231;
static double earthRotationsY earDecrement = 0.00000006;
static double earthRotations1 00YearDecrement = 0.000006;
private static void leapTest( long yearModulo, long yearStop) {
long intDays0 = 0;
long intDays1 = 0;
double floatDays0 = 0.0;
double floatDays1 = 0.0;
double floatDays1PerYe arDecrement = 0.0;

for( long i=0; i<yearStop; i++) {

floatDays0 += earthRotationsP erYear0 - (i * earthRotationsY earDecrement);

if ((( i+1) % 100) == 0)
floatDays1PerYe arDecrement += earthRotations1 00YearDecrement ;
floatDays1 += earthRotationsP erYear0 - floatDays1PerYe arDecrement;

intDays0 += 365;
if ((( i+1) % 4) == 0) {
if ((( i+1) % 100) != 0)
intDays0++;
else if ((( i+1) % 400) == 0)
intDays0++;
}
intDays1 += 365;
if ((( i+1) % 4) == 0) {
if ((( i+1) % 128) != 0)
intDays1++;
}

if ((( i+1) % yearModulo) == 0) {
System.out.prin tln( " Year = " + (i+1) );
System.out.prin tln( " Days Float0 = " + floatDays0 );
System.out.prin tln( " Days Float1 = " + floatDays1 );
System.out.prin tln( " Days Gregorian = " + intDays0 );
System.out.prin tln( " Days intDays1 = " + intDays1 );

}
} // end for
} // end leapTest

public static void main(String[] args) {
if (args.length != 2) {
System.err.prin tln("Usage: java leap2 " +
"<year modulo> <year end>");
}
else {
try {
leapTest( Long.parseLong( args[0], 10), Long.parseLong( args[1], 10) );
} catch (Exception e) {
System.err.prin tln(
"Exception Error:" + e.getMessage()) ;
}
}
}

} // End of public class leap2
Jul 17 '05 #4
Mark A. Washburn wrote:
The Julian Calendar, adopted in 46BC by Julius Caesar, adds one day every
four years to correct for the fact that Earth's solar year is slightly more
than 365 of Earth's daily rotations. ( 365.25 days per year)

The Gregorian Calendar, adopted in 1582 by Pope Gregory XIII, ordered that
leap years should not occur in years ending in '00', unless divisible by
400. ( 365.2475 days per year)

A modern estimate of a calendar year is 365.24219 rotations of Earth per
solar year.
Calendar days since 46BC
46BC = 366
(( 2004 + 46) * 365) = 748250
(( 2004 + 46) / 4) = 512
( 1600, 2000) = -2
= 749126
You forgot the 11 days they nicked off us in 1752 or whenever it was in
your bit of the world. And by the way, it's the hundreds that weren't
leap years that you should be subtracting, not the hundreds that were
leap years.

<snip> An even more modern calendar error correction rule can be stated as,
add one day every four years, using February 29th, unless the year is
exactly divisible by 128. ( 365.2421875) This may accumulate 1 Earth
rotational day error for every hundred thousand solar years.


That wouldn't exactly border on being backward compatible. OTOH, if we
try correcting the Gregorian, rather than the Julian.

Let's look at the Gregorian more simply.

Calendar days from 1 to 2000:
2000 * 365 = 730000
2000 / 4 = 500
-2000 / 100 = -20
2000 / 400 = 5

Total = 730485

Actual days from 1 to 2000:
= 730484.38

So as of 1 Jan 2001, we're only .62 of a day out. So if we dropped a
leap year every 3200 years on the Gregorian, we'd have:

Calendar days from 1 to 3200:
3200 * 365 = 1168000
3200 / 4 = 800
-3200 / 100 = -32
3200 / 400 = 8
-3200 / 3200 = -1

Total = 1168775

Actual days from 1 to 3200:
= 1168775.008

This'll be plenty of time for the world to fix any Y3.2K problems.

And then for your (great-){15998,39998}g randchildren, drop another leap
year every 400000 years. Then our calendar'll be perfect. :-)

Stewart.

--
My e-mail is valid but not my primary mailbox, aside from its being the
unfortunate victim of intensive mail-bombing at the moment. Please keep
replies on the 'group where everyone may benefit.
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2092
by: Sugapablo | last post by:
Can someone recommend a very simple script to produce a web calendar? I just want something where I can select a month and year and it produces a very basic HTML table, 7 columns across, one month at a time, with the dates filled in. No frills, no nothing, just pure, month producing code. --
2
14882
by: cg_news | last post by:
In short, what I am trying to do is, based on a date, calculate the week of year (as described in ISO 8601), then calculate the first and last date in this week period and return them in the format CCYYMMDD. Sounds easy enough, right?? I am attempting to accomplish this by creating a GregorianCalender which will get me the week of year. Then by changing the day of week to 1 (start of week) i'm trying the get the first day of the week,...
2
3419
by: Caesar Augustus | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many controls (i.e. roundedcorners component www.4guysfromrolla.com], buttons and panels) functions like a tab control. The buttons are programmatically designed to make the corresponding panel visible. Sample aspx.vb code:
0
1721
by: R.A.M. | last post by:
Hello, I need to implement popup calendar in ASP.NET application. I created a button opening popup calendar on 'master' page: <asp:Button ID="Calendar" runat="server" Text=Calendar" OnClientClick= "window.open('Calendar.aspx', 'Calendar', 'menubar=no, location=no, personalbar=no, status=no, resizable=no, scrollbars=no, width=200, height=200');" />
1
2736
by: R.A.M. | last post by:
Hello, I need to implement popup calendar in ASP.NET application. I created a button opening popup calendar on 'master' page: <asp:Button ID="Calendar" runat="server" Text=Calendar" OnClientClick= "window.open('Calendar.aspx', 'Calendar', 'menubar=no, location=no, personalbar=no, status=no, resizable=no, scrollbars=no, width=200, height=200');" />
0
2019
by: GV | last post by:
Hi all, New to developing in VS 2005 ASP 2.0 Trying to have a easy pop calender for a button on a web page. I keep getting a error message in IE6 that says: Line 69 Char 3 Error: 'this.container' is null or not an object
3
2743
by: thorpk | last post by:
I posted this problem earlier in the month and some one decided it was better to change the subject and ask a completely different question. I am therefore reposting. I am hoping some one can assist with this. Thanks in advance. I have an access database that i have added a pop up calendar to, the Table information for the Date Reported field is Date/Time format short date, input mask is 00/00/0000.
0
3329
by: mathewgk80 | last post by:
HI all, I am having popup calendar Javascript code. But i dont know how it is connecting to asp.net code.. I am using asp.net,c#.net and also using 3tier architecture with master page.... I would like to get the code for connecting the javascript to asp.net page... Please help me... The javascript code is as follows..
4
3378
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters the comments and clicks the save button then the date and the date will be stored in the mysql database. This is working fine. But my problem is when, after the user had made an entry the date in the calendar for which an entry has made should be...
1
3714
by: abhishekbrave | last post by:
The code below is opening a calendar on mouse over in the same window. I need the calendar to be opened in new window. Have to fulfill this requirement urgentely so posting the whole code here. I tried doing some workaround using window.open() but not getting the calendar in new window. <html> <head> <script language="JavaScript">
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9593
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10088
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9169
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7633
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.