dc21d42001-05-05Mirar (Pontus Hagland) //! //! module Calendar //! submodule Julian //! inherits YMD //!
5561652000-09-27Mirar (Pontus Hagland) //! This is the Julian calendar, conjured up by
dc21d42001-05-05Mirar (Pontus Hagland) //! the old Romans when their calendar were just too
334e872003-03-12Marcus Agehall //! weird. It was used by the christians as so far
dc21d42001-05-05Mirar (Pontus Hagland) //! as the 18th century in some parts of the world.
5561652000-09-27Mirar (Pontus Hagland) //! (Especially the protestantic and orthodox parts.) //!
dc21d42001-05-05Mirar (Pontus Hagland) //! note: //! Don't confuse the <i>julian day</i> with the Julian
5561652000-09-27Mirar (Pontus Hagland) //! calendar. The former is just a linear numbering of days, //! used in the Calendar module as a common unit for //! absolute time.
a580e12000-09-27Fredrik Hübinette (Hubbe) #pike __REAL_VERSION__
2232742000-09-27Mirar (Pontus Hagland) 
5561652000-09-27Mirar (Pontus Hagland) import "."; inherit Gregorian:Gregorian; 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 }