a580e12000-09-27Fredrik Hübinette (Hubbe) #pike __REAL_VERSION__
2232742000-09-27Mirar (Pontus Hagland) 
5479552003-03-13Martin Nilsson //! This is the Julian calendar, conjured up by //! the old Romans when their calendar were just too //! weird. It was used by the christians as so far //! as the 18th century in some parts of the world. //! (Especially the protestantic and orthodox parts.) //! //! @note //! Don't confuse the @i{julian day@} with the Julian //! calendar. The former is just a linear numbering of days, //! used in the Calendar module as a common unit for //! absolute time. inherit .Gregorian:Gregorian;
5561652000-09-27Mirar (Pontus Hagland)  string calendar_name() { return "Julian"; } static int year_leap_year(int y) { return !((y)%4); }
ac87a71998-01-19Marcus Comstedt 
5561652000-09-27Mirar (Pontus Hagland) // [y,yjd] static array year_from_julian_day(int jd)
ac87a71998-01-19Marcus Comstedt {
5561652000-09-27Mirar (Pontus Hagland)  int d=jd-1721058;
ac87a71998-01-19Marcus Comstedt 
5561652000-09-27Mirar (Pontus Hagland)  int quad=d/1461; int quad_year=max( (d%1461-1)/365, 0);
ac87a71998-01-19Marcus Comstedt 
5561652000-09-27Mirar (Pontus Hagland)  return ({ quad*4+quad_year, 1721058+1461*quad+365*quad_year+!!quad_year });
78fd532000-07-12Mirar (Pontus Hagland) }
5561652000-09-27Mirar (Pontus Hagland) static int julian_day_from_year(int y)
78fd532000-07-12Mirar (Pontus Hagland) {
5561652000-09-27Mirar (Pontus Hagland)  y--; return 1721424+y*365+y/4;
ac87a71998-01-19Marcus Comstedt }