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.
9f0b6c2008-02-07Martin Stjernholm inherit Calendar.Gregorian:Gregorian;
5561652000-09-27Mirar (Pontus Hagland)  string calendar_name() { return "Julian"; }
3524712015-05-26Martin Nilsson protected int year_leap_year(int y) {
5561652000-09-27Mirar (Pontus Hagland)  return !((y)%4); }
ac87a71998-01-19Marcus Comstedt 
5561652000-09-27Mirar (Pontus Hagland) // [y,yjd]
9eaf1d2008-06-28Martin Nilsson protected 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 
3524712015-05-26Martin Nilsson  return
5561652000-09-27Mirar (Pontus Hagland)  ({ quad*4+quad_year, 1721058+1461*quad+365*quad_year+!!quad_year });
78fd532000-07-12Mirar (Pontus Hagland) }
9eaf1d2008-06-28Martin Nilsson protected 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 }