Re: Help with dates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Kevin wrote:
Dear mr. Maas,

no need for 'mr' :-)


First of all my appologies for taking so long to respond. I had a family death to attend to.

my condolences. there is no need to apologise in any case.

...


why is OBC relevant, I read later on that you take the start of egyptian civilization as zero. is that not much earlier.


Well it's relevant to make a baseline so that I can calculate the difference
from then until now. That's the only reason thusfar.


whats the structure of the egyptian|rpg calendar?


A year consists of 769 days, 13 months of 63 days a month, except for month
13 which has 14 days. Every month has 7 weeks of 9 days, of course month 13
is the exception. A day is 24 hours.


a few thoughts:

1. you have a date in both calendars which represent the same day?
and/or rather what is day zero in the egyptian calendar in the gregorian
calendar?

2. maybe you should store the date internally as number of days since zero,
where zero is the first day on the egyptian calendar ......

er, checking this thread again, Richard Lynch puts it better than I can so
I'll just let you read his answer (again?) and hope it helps!


oh one last thing: I notice that in the function you posted you did this:


# Calculating the year in Egypt. $yr_Egypt = floor($EgyptianDays / 769); # Calculating the Month in Egypt. $mnt_Egypt = round( ($EgyptianDays-($yr_Egypt*769)) / 63 ); # Calculating the Day in Egypt. $dy_Egypt = round( $EgyptianDays - (($yr_Egypt * 769) + ($mnt_Egypt * 63)) ); # Filling the date array variable with the day, month and year of the Egyptian calendar. $ec_date["Day"] = $dy_Egypt; $ec_date["Month"] = $mnt_Egypt; $ec_date["Year"] = $yr_Egypt; # Returning the Calculated date. return $ec_date;

which could be written more succinctly as:


/* Calculating the year,month,day in Egypt and returning. */ return array ( "Year" => ($y = floor( $EgyptianDays / 769 )), "Month" => ($m = round( ($EgyptianDays - ($y * 769)) / 63 )), "Day" => round( $EgyptianDays - (($y * 769) + ($m * 63)) ), );

that might inspire you to use less variables in your code, which is a good thing - but in this
case completely beside the point. whats less beside the point is that you use floor() for the year
and round() for the day and month, I wonder if it helps if you use floor() for all 3?

beware of floating point rounding errors, compare:

<?php

$EgyptianDays = 10345;

var_dump(

array(
    "Year"  => ($y = floor(  $EgyptianDays / 769 )),
    "Month" => ($m = floor( ($EgyptianDays -  ($y * 769)) / 63 )),
    "Day"   => floor(  $EgyptianDays - (($y * 769) + ($m * 63)) ),
),

array(
    "Year"  => ($y = floor(  $EgyptianDays / 769 )),
    "Month" => ($m = round( ($EgyptianDays -  ($y * 769)) / 63 )),
    "Day"   => round(  $EgyptianDays - (($y * 769) + ($m * 63)) ),
)

);

?>

kind regards,
Jochem

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux