5561652000-09-27Mirar (Pontus Hagland) //! This is the Julian calendar, conjured up by
55f4ec2001-04-27Henrik Grubbström (Grubba) //! the old Romans when their calendar was just too //! wierd. It was used by the christians so far as //! to the 18th century in some parts of the world.
5561652000-09-27Mirar (Pontus Hagland) //! (Especially the protestantic and orthodox parts.) //!
55f4ec2001-04-27Henrik Grubbström (Grubba) //! @note //! Don't confuse the @i{julian day@} 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 ".";
55f4ec2001-04-27Henrik Grubbström (Grubba)  //! inherits YMD
5561652000-09-27Mirar (Pontus Hagland) 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 }