zarqon
Well-known member
I rigged up some functions for a script I'm writing which might be useful to the mafia community. One function returns the current KoL day (which I know is accessible elsewhere but this makes it easy), and another one takes a real-world date and returns the corresponding date in the KoL calendar.
I'm using this to calculate clan member "birthdays." I get their sign-on date by visiting showplayer.php, then compare date_to_kol(thedate) with today() to see if it's that clannie's KoL-calendar birthday (not real-world KoL birthday).
This could also be used as an alternative method for calculating stat days or holidays, since they always fall on certain KoL calendar days.
date_to_kol() accepts a wide variety of formats. You could pass "12/25/2007" or "December 25th, 2007" or "2007 Dec 12" or just about any human-readable date format. Even more useful, you can also give it relative input like "+3 days", which will return the KoL date three days from today. "-1 day" gives you yesterday, and so on.
You'll notice I do all the processing in PHP rather than ASH, since ASH has very very little by way of date/time functions. Also, the PHP page that these functions visit behaves differently depending on whether you're accessing it via mafia vs. a web browser.
I'm using this to calculate clan member "birthdays." I get their sign-on date by visiting showplayer.php, then compare date_to_kol(thedate) with today() to see if it's that clannie's KoL-calendar birthday (not real-world KoL birthday).
This could also be used as an alternative method for calculating stat days or holidays, since they always fall on certain KoL calendar days.
Code:
string date_to_kol(string realworld) {
return visit_url("http://zachbardon.com/mafiatools/datetokol.php?d="+url_encode(realworld));
}
string today() {
return visit_url("[url]http://zachbardon.com/mafiatools/datetokol.php"[/url]);
}
date_to_kol() accepts a wide variety of formats. You could pass "12/25/2007" or "December 25th, 2007" or "2007 Dec 12" or just about any human-readable date format. Even more useful, you can also give it relative input like "+3 days", which will return the KoL date three days from today. "-1 day" gives you yesterday, and so on.
You'll notice I do all the processing in PHP rather than ASH, since ASH has very very little by way of date/time functions. Also, the PHP page that these functions visit behaves differently depending on whether you're accessing it via mafia vs. a web browser.