Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Function to find the day of the week

Author
Message
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 25th Apr 2017 18:30
Here is a function that returns the day of the week for what ever date you send to it.



What would be REALLY cool is a plugin that does formatting for time, date, currency, all the usual stuff that can be formatted.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Apr 2017 00:10
I remember writing that function in java class. I don't recall the exact algorithm offhand.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 29th Apr 2017 09:01
Thank you
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 29th Apr 2017 17:20 Edited at: 29th Apr 2017 17:21
Thank you. Although I have no idea how it works...
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Apr 2017 20:20
Here's the commonly known method.
https://cs.uwaterloo.ca/~alopez-o/math-faq/node73.html

Rich seems to be taking a different approach.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Richard Dersheimer
8
Years of Service
User Offline
Joined: 15th Mar 2016
Location:
Posted: 30th Apr 2017 21:09
GetUnixFromDate
Converts a given date an time into its unix time equivalent, unix time is the number of seconds since 1st Jan 1970. If not using 64 bit values then the unix time value is limited to 1901 to 2038 for the year.
This already takes leap years into account (but not leap seconds) so you don't need any fancy calculations for that.

The number of seconds divided by 86400 is the number of days since 1st Jan 1970.

And then mod 7 returns the remainder of those days divided by 7.

If you know that 1st Jan 1970 was a Thursday, and the remainder is 1, then you know the day of the week for that date is Friday.

Login to post a reply

Server time is: 2024-11-24 17:03:06
Your offset time is: 2024-11-24 17:03:06