home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / dev / Libraries / Date / src / Date.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-18  |  9.1 KB  |  141 lines

  1. /* Copyright 1994-95 by Kai Hofmann */
  2.  
  3. #ifdef _AMIGA
  4.    #define _ISO8859_Latin1
  5. #endif
  6. #ifndef BOOLEAN
  7.   typedef short bool;
  8.   #define true    1
  9.   #define false    0
  10.   #define BOOLEAN
  11. #endif
  12. #ifndef DATELIB
  13.   typedef enum
  14.     #if defined(__cplusplus) && defined(__SASC_650)
  15.       WeekdaysENUM
  16.     #endif
  17.                {dayerr,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday} Weekdays;
  18.   typedef enum
  19.     #if defined(__cplusplus) && defined(__SASC_650)
  20.       MoonPhasesENUM
  21.     #endif
  22.                {NewMoon,FirstQuarter,FullMoon,LastQuarter} MoonPhases;
  23.   typedef enum
  24.     #if defined(__cplusplus) && defined(__SASC_650)
  25.       DateTextsENUM
  26.     #endif
  27.                {DAY,MONTH,YEAR,WEEK,WEEKDAY,HOUR,MINUTE,SECOND,YESTERDAY,TODAY,TOMORROW} DateTexts;
  28.   #define DATELIB
  29. #endif
  30. #ifndef LOCALE
  31.   typedef enum
  32.     #if defined(__cplusplus) && defined(__SASC_650)
  33.       LanguagesENUM
  34.     #endif
  35.               {Locale,English,Deutsch,
  36.                 #ifdef _ISO8859_Latin1
  37.                   français,español,português,
  38.                 #else
  39.                   francais,espanol,portugues,
  40.                 #endif
  41.                 dansk,italiano,nederlands,norsk,svenska,polski,suomalainen
  42.                } Languages;
  43.   typedef enum
  44.     #if defined(__cplusplus) && defined(__SASC_650)
  45.       CountriesENUM
  46.     #endif
  47.                {unknown,Italia,Deutschland,Schweiz,Danmark,Nederland,GreatBritain} Countries;
  48.   #define LOCALE
  49. #endif
  50.  
  51. /* Module initialization */
  52. #ifndef __SASC_650
  53.   void _DateInit(void);
  54.   void _DateCleanup(void);
  55.   #undef __MakeLib
  56. #endif
  57.  
  58. #ifndef __MakeLib
  59.   bool JulianLeapYear(const int year);
  60.   bool GregorianLeapYear(const int year);
  61.   bool HeisLeapYear(const int year);
  62.   unsigned short JulianMonthDays(const unsigned short month, const int year);
  63.   unsigned short GregorianMonthDays(const unsigned short month, const int year);
  64.   unsigned short HeisMonthDays(const unsigned short month, const int year);
  65.   unsigned int JulianYearDays(const int year);
  66.   unsigned int GregorianYearDays(const int year);
  67.   unsigned int HeisYearDays(const int year);
  68.   short Compare2Dates(const unsigned short day1, const unsigned short month1, const int year1, const unsigned short day2, const unsigned short month2, const int year2);
  69.   long JulianDayDiff(const unsigned short day1, unsigned short month1, int year1, const unsigned short day2, unsigned short month2, int year2);
  70.   long GregorianDayDiff(const unsigned short day1, unsigned short month1, int year1, const unsigned short day2, unsigned short month2, int year2);
  71.   long HeisDayDiff(const unsigned short day1, unsigned short month1, int year1, const unsigned short day2, unsigned short month2, int year2);
  72.   Weekdays JulianWeekday(const unsigned short day, unsigned short month, int year);
  73.   Weekdays GregorianWeekday(const unsigned short day, unsigned short month, int year);
  74.   Weekdays HeisWeekday(const unsigned short day, unsigned short month, int year);
  75.   unsigned short JulianDaysBeforeWeekday(const unsigned short day, const unsigned short month, const int year, const Weekdays weekday);
  76.   unsigned short GregorianDaysBeforeWeekday(const unsigned short day, const unsigned short month, const int year, const Weekdays weekday);
  77.   unsigned short HeisDaysBeforeWeekday(const unsigned short day, const unsigned short month, const int year, const Weekdays weekday);
  78.   unsigned short JulianDaysAfterWeekday(const unsigned short day, const unsigned short month, const int year, const Weekdays weekday);
  79.   unsigned short GregorianDaysAfterWeekday(const unsigned short day, const unsigned short month, const int year, const Weekdays weekday);
  80.   unsigned short HeisDaysAfterWeekday(const unsigned short day, const unsigned short month, const int year, const Weekdays weekday);
  81.   unsigned int JYearToScaliger(const int year);
  82.   unsigned int GYearToScaliger(const int year);
  83.   unsigned int HYearToScaliger(const int year);
  84.   int ScaligerYearToJ(const unsigned int syear);
  85.   int ScaligerYearToG(const unsigned int syear);
  86.   int ScaligerYearToH(const unsigned int syear);
  87.   unsigned long JSYearToJD(const unsigned int syear);
  88.   unsigned long GSYearToJD(const unsigned int syear);
  89.   unsigned long HSYearToJD(const unsigned int syear);
  90.   unsigned long JDtoMJD(const unsigned long jd);
  91.   unsigned long MJDtoJD(const unsigned long mjd);
  92.   unsigned long JulianToJD(const unsigned short day, const unsigned short month, const int year);
  93.   unsigned long GregorianToJD(const unsigned short day, const unsigned short month, const int year);
  94.   unsigned long HeisToJD(const unsigned short day, const unsigned short month, const int year);
  95.   unsigned short GregorianMoonAge(const unsigned short day, const unsigned short month, const int year);
  96.   unsigned short JulianWeek(const unsigned short day, const unsigned short month, const int year);
  97.   unsigned short GregorianWeek(const unsigned short day, const unsigned short month, const int year);
  98.   unsigned short HeisWeek(const unsigned short day, const unsigned short month, const int year);
  99.   unsigned short WeekdayText(const Weekdays wday, char *const wtext, Languages lang);
  100.   unsigned short MonthText(const unsigned short month, char *const mtext, Languages lang);
  101.   unsigned short WeekdayShortText(const Weekdays wday, char *const wtext, Languages lang);
  102.   unsigned short MonthShortText(const unsigned short month, char *const mtext, Languages lang);
  103.   unsigned long GregorianMoonPhase(const unsigned short day, const unsigned short month, const int year, const MoonPhases phase);
  104.   void DateText(const DateTexts text, char *const mtext, Languages lang, const bool plural);
  105.   bool ValidJulianDate(const unsigned short day, const unsigned short month, const int year);
  106.   bool ValidGregorianDate(const unsigned short day, const unsigned short month, const int year);
  107.   bool ValidHeisDate(const unsigned short day, const unsigned short month, const int year);
  108.   void SetCountry(const Countries country);
  109.   #include "Date_Time.h"
  110.   #ifndef __cplusplus
  111.     void JulianDiffDate(const unsigned short day, const unsigned short month, const int year, int days, unsigned short *const dday, unsigned short *const dmonth, int *const dyear);
  112.     void GregorianDiffDate(const unsigned short day, const unsigned short month, const int year, int days, unsigned short *const dday, unsigned short *const dmonth, int *const dyear);
  113.     void HeisDiffDate(const unsigned short day, const unsigned short month, const int year, int days, unsigned short *const dday, unsigned short *const dmonth, int *const dyear);
  114.     void JDToJulian(const unsigned long jd, unsigned short *const day, unsigned short *const month, int *const year);
  115.     void JDToGregorian(const unsigned long jd, unsigned short *const day, unsigned short *const month, int *const year);
  116.     void JDToHeis(const unsigned long jd, unsigned short *const day, unsigned short *const month, int *const year);
  117.     void JulianEaster(const int year, unsigned short *const dday, unsigned short *const dmonth);
  118.     void GregorianEaster(const int year, unsigned short *const dday, unsigned short *const dmonth);
  119.     void HeisEaster(const int year, unsigned short *const dday, unsigned short *const dmonth);
  120.   #else
  121.     void JulianDiffDate(const unsigned short day, const unsigned short month, const int year, int days, unsigned short &dday, unsigned short &dmonth, int &dyear);
  122.     void GregorianDiffDate(const unsigned short day, const unsigned short month, const int year, int days, unsigned short &dday, unsigned short &dmonth, int &dyear);
  123.     void HeisDiffDate(const unsigned short day, const unsigned short month, const int year, int days, unsigned short &dday, unsigned short &dmonth, int &dyear);
  124.     void JDToJulian(const unsigned long jd, unsigned short &day, unsigned short &month, int &year);
  125.     void JDToGregorian(const unsigned long jd, unsigned short &day, unsigned short &month, int &year);
  126.     void JDToHeis(const unsigned long jd, unsigned short &day, unsigned short &month, int &year);
  127.     void JulianEaster(const int year, unsigned short &dday, unsigned short &dmonth);
  128.     void GregorianEaster(const int year, unsigned short &dday, unsigned short &dmonth);
  129.     void HeisEaster(const int year, unsigned short &dday, unsigned short &dmonth);
  130.   #endif
  131.  
  132.   /* This are old routines that should not longe be used! They appear here only for compatibility to old releases! */
  133.   bool JulianDaySmaller(const unsigned short day1, const unsigned short month1, const int year1, const unsigned short day2, const unsigned short month2, const int year2);
  134.   bool GregorianDaySmaller(const unsigned short day1, const unsigned short month1, const int year1, const unsigned short day2, const unsigned short month2, const int year2);
  135.   bool HeisDaySmaller(const unsigned short day1, const unsigned short month1, const int year1, const unsigned short day2, const unsigned short month2, const int year2);
  136.   bool JulianDayGreater(const unsigned short day1, const unsigned short month1, const int year1, const unsigned short day2, const unsigned short month2, const int year2);
  137.   bool GregorianDayGreater(const unsigned short day1, const unsigned short month1, const int year1, const unsigned short day2, const unsigned short month2, const int year2);
  138.   bool HeisDayGreater(const unsigned short day1, const unsigned short month1, const int year1, const unsigned short day2, const unsigned short month2, const int year2);
  139. #else
  140. #endif
  141.