flat assembler
Message board for the users of flat assembler.

Index > Heap > Calculating Calender Correctly

Author
Thread Post new topic Reply to topic
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?? Very Happy
Post 17 Feb 2015, 07:42
View user's profile Send private message Reply with quote
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) Very Happy

Mom?
Post 17 Feb 2015, 08:03
View user's profile Send private message Reply with quote
Walter



Joined: 26 Jan 2013
Posts: 143
Walter
Post 17 Feb 2015, 08:37
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6038
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

Wink
Post 17 Feb 2015, 09:13
View user's profile Send private message Visit poster's website Reply with quote
Walter



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

Code:
<html>
<head>
<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>
</head>
<body style="font-size:14px;background:#bbddff;">

<div style="padding:10.0em;">
<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:

Image

Also check here: There is also C code.
Post 17 Feb 2015, 09:45
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 648
l4m2
what about time()
Post 03 Mar 2015, 07:32
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17352
Location: In your JS exploiting you and your system
revolution
l4m2 wrote:
what about time()
What about it? What is it? Does it require an OS in the background to provide the results?
Post 03 Mar 2015, 07:42
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 648
l4m2
revolution wrote:
l4m2 wrote:
what about time()
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
Post 03 Mar 2015, 10:02
View user's profile Send private message Reply with quote
gens



Joined: 18 Feb 2013
Posts: 161
gens
l4m2 wrote:
revolution wrote:
l4m2 wrote:
what about time()
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
Post 03 Mar 2015, 15:14
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.