Author Topic: Alternative Calendar  (Read 583 times)

Offline Sunchaser

  • Game Owner
  • Level 23
  • *
  • Posts: 296
  • Reputation: +3/-0
  • Game Owner
    • View Profile
    • Medieval Europe
Alternative Calendar
« on: March 21, 2010, 10:38:55 AM »
I would like to post game event of a game set in medieval time,
but the event time i would like to print however should be around year 1200-1300;

For example, if a event happens at 10 PM today i would like to show the timestamp as 21 March, 1278 or maybe, 21 March XIX.

How can i "convert" actual timestamp in a past calendar and / or, convert the year in romans numbers?

Do anyone have suggestions or some useful links/tutorials?

Thanks.

Offline Mufasa

  • Game Owner
  • Level 18
  • *
  • Posts: 189
  • Reputation: +3/-0
  • Maniac Developer
    • View Profile
Re: Alternative Calendar
« Reply #1 on: March 21, 2010, 12:25:33 PM »
well if it's going to be always 1,000 years earlier, you could always do:


$year = date( "Y", $timestamp ) - 1000;
that'll give you 1010.

So if you're targeting 1200 as your year, that's 810 years ago, so subtract 810 from all your timestamps.

You could also do it a bit less accurately like so:

$timestamp -= 25544160000; //86400 * 365 * 810
echo date( "m/d/Y", $timestamp );

86400 seconds in a day, and 365 days in a year, times 810 years. This doesn't take leap years into account though, so it'll be a day off for every 4 years.

Offline Sunchaser

  • Game Owner
  • Level 23
  • *
  • Posts: 296
  • Reputation: +3/-0
  • Game Owner
    • View Profile
    • Medieval Europe
Re: Alternative Calendar
« Reply #2 on: March 21, 2010, 12:41:53 PM »
I thought about that, my problem was the leap year, but i think i can live with that XD

Offline Mufasa

  • Game Owner
  • Level 18
  • *
  • Posts: 189
  • Reputation: +3/-0
  • Maniac Developer
    • View Profile
Re: Alternative Calendar
« Reply #3 on: March 21, 2010, 12:51:14 PM »
well the first example will do the leap year for you. Or you can do:

Code: [Select]
// get timestamp for the beginning of this day, 810 years ago
$oldtime = mktime(0,0,0,date('m'),date('d'),date('Y')-810);

you could also make this info a function

Code: [Select]
function makeOldTime( $timestamp ){
$oldtime = mktime( date('g', $timestamp), date('i', $timestamp), date('s', $timestamp), date('m', $timestamp), date('d', $timestamp), date('Y', $timestamp) - 810 );
return $oldtime;
}

probably more elegant ways of doing it too, but that'll get the job done. So you can store timestamps as usual, but pass them to this function if you want them to be converted to 810 years ago.

Offline Harkins

  • Level 28
  • **
  • Posts: 424
  • Reputation: +11/-2
  • Coder, blogger, entrepreneur.
    • View Profile
    • Push CX - Blog
Re: Alternative Calendar
« Reply #4 on: March 21, 2010, 04:52:03 PM »
I thought about that, my problem was the leap year, but i think i can live with that XD

Subtract a number of years that is evenly divisible by 4. It'll be wrong in 2100, but players will probably not notice that 1310 was not actually a leap year.

Visit #bbg on irc.freenode.net to talk browser games anytime.

Offline dsheroh

  • Level 21
  • *
  • Posts: 235
  • Reputation: +6/-0
  • Perl Vicar
    • View Profile
    • Psi Rangers
Re: Alternative Calendar
« Reply #5 on: March 21, 2010, 06:35:18 PM »
...or you can just ignore leap years entirely, since anything based on using the current calendar date will be inherently incorrect anyhow.  The Gregorian calendar (i.e., the one you and I use on a daily basis) was not adopted until 1582.  You're not going to get accurate 13th-century dates unless you use a date/time library which is smart enough to calculate Julian dates as offsets from a Gregorian date.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal