flat assembler
Message board for the users of flat assembler.

 Index > Heap > Calculating Calender Correctly
Author
system error

Joined: 01 Sep 2013
Posts: 671
system error
I found an algorithm in JAPANESE some years ago that can correctly determine future date. I used it in my java code. The accuracy is impressive. Only one problem; I lost the code and I can't remember the web source of that lengthy formula. I can't read or write japanese so I can't use google to look it up.

Help??
17 Feb 2015, 07:42
system error

Joined: 01 Sep 2013
Posts: 671
system error
The formula was just a plain math expression but lengthy. That's the only part that I understood. I translated it into Java and it worked wonders. Other than that, it was in Japanese all the way. Something like this;

%\$#! date *&^^# day=(formula) #@4)9>=##

(garbage is in japanese)

Mom?
17 Feb 2015, 08:03
Walter

Joined: 26 Jan 2013
Posts: 143
Walter
17 Feb 2015, 08:37
MHajduk

Joined: 30 Mar 2006
Posts: 6034
Location: Poland
MHajduk
Some time ago I wrote with FASM a set of procedures that can deal with calendar (both Gregorian and Julian styles). Here you have a short description taken from the source of the DLL library:
Quote:
Calendar functions library written with FASM assembler.

Abilities:
* works with dates from the interval of 11 million years:
- from 1 Jan 5843880 BCE to 3 Aug 5915100 for the Julian calendar,
- from 30 Dec 5844001 BCE to 17 Jan 5915222 for the Gregorian calendar,
* convenient conversions between Julian and Gregorian calendars for dates from supported time interval,
* calculation of the day of the week for the given date,
* calculation of the number of the day in the year,
* determining if the given year is leap in chosen calendar,
* calculation of the "absolute" day number for the given date (it could be used to calculation of the distance between two dates).
Take a look here: http://mikhajduk.houa.org/EN/Calendar.php

17 Feb 2015, 09:13
Walter

Joined: 26 Jan 2013
Posts: 143
Walter
Here is a Javascript in HTML that will calculate the day of the week.

Code:
```<html>
<title>Zeller's Congruence</title>
<script type="text/javascript">

/***
*
*      /    |(m+1)*26|       | y |       | y |   | y |    \
* h = | q + |--------| + y + |---| + 6 * |---| + |---| - 1 | mod 7
*      \    |   10   |       | 4 |       |100|   |400|    /
*
***/
function zeller(month, day, year) /* returns 0-6 where 0=sunday, 1=monday, etc....*/
{
if (month < 3) { month += 12; year -= 1; }
var h = (day + parseInt(((month + 1) * 26) / 10) + year + parseInt(year / 4) + 6 * parseInt(year / 100) + parseInt(year / 400) - 1) % 7;
return h;
}

function demo(month, day, year)
{
var mons = ['January','February','March','April','May','June','July','August','September','October','November','December'];
var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
return mons[month-1] + ' ' + day + ', ' + year + ' = ' + days[zeller(month, day, year)];
}

</script>
<body style="font-size:14px;background:#bbddff;">

<p>Zeller's Congruence Demo</p>
<p><textarea style="font-family:sans-serif;width:5em;height:1.5em;" id="month"></textarea>&nbsp;Enter the Month</p>
<p><textarea style="font-family:sans-serif;width:5em;height:1.5em;" id="day"></textarea>&nbsp;Enter the Day</p>
<p><textarea style="font-family:sans-serif;width:5em;height:1.5em;" id="year"></textarea>&nbsp;Enter the Year</p>
<p><input type="button" value="Submit" filtered="doDemo();" /></p>
<p id="result">----------</p>
</div>

<script type="text/javascript">
function doDemo()
{
var m = parseInt(document.getElementById('month').value);
var d = parseInt(document.getElementById('day').value);
var y = parseInt(document.getElementById('year').value);
document.getElementById('result').innerHTML = demo(m,d,y);
}
</script>
</body>
</html>
```

Output:

Also check here: There is also C code.
17 Feb 2015, 09:45
l4m2

Joined: 15 Jan 2015
Posts: 648
l4m2
03 Mar 2015, 07:32
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 17279
revolution
l4m2 wrote:
What about it? What is it? Does it require an OS in the background to provide the results?
03 Mar 2015, 07:42
l4m2

Joined: 15 Jan 2015
Posts: 648
l4m2
revolution wrote:
l4m2 wrote:
What about it? What is it? Does it require an OS in the background to provide the results?
Or i can say 400 years later has the same weekname as today
03 Mar 2015, 10:02
gens

Joined: 18 Feb 2013
Posts: 161
gens
l4m2 wrote:
revolution wrote:
l4m2 wrote:
What about it? What is it? Does it require an OS in the background to provide the results?
Or i can say 400 years later has the same weekname as today

idk about weeknames, but in 400 years dates will be "stardates"
and there will blue man group like people running around... with antennae on their heads
03 Mar 2015, 15:14
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsCompiler InternalsIDE DevelopmentOS ConstructionNon-x86 architecturesHigh Level LanguagesProgramming Language DesignProjects and IdeasExamples and Tutorials Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou can attach files in this forumYou can download files in this forum