converter.h
1 /***************************************************************************
2  * Copyright (C) 2003 by Jonathan Singer *
3  * jsinger@leeta.net *
4  * Calendar routines from Hebrew Calendar by Frank Yellin *
5  * *
6  * This program is free software; you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as published by *
8  * the Free Software Foundation; either version 2 of the License, or *
9  * (at your option) any later version. *
10  ***************************************************************************/
11 #ifndef CONVERTER_H
12 #define CONVERTER_H
13 
14 #include <tqstring.h>
15 #include <tqstringlist.h>
16 
17 struct DateResult
18 {
19  int year;
20  int month;
21  int day;
22  int day_of_week;
23 
24  int hebrew_month_length, secular_month_length;
25  bool hebrew_leap_year_p, secular_leap_year_p;
26  int kvia;
27  int hebrew_day_number;
28 };
29 
33 class Converter
34 {
35 public:
36 
37  Converter();
38  ~Converter();
39 
40  static bool hebrew_leap_year_p(int year);
41  static bool gregorian_leap_year_p(int year);
42 
43  static long absolute_from_gregorian(int year, int month, int day);
44  static long absolute_from_hebrew(int year, int month, int day);
45 
46  static void gregorian_from_absolute(long date, int *yearp,
47  int *monthp, int *dayp);
48  static void hebrew_from_absolute(long date, int *yearp, int *monthp,
49  int *dayp);
50 
51  static int hebrew_months_in_year(int year);
52  static int hebrew_month_length(int year, int month);
53  static int secular_month_length(int year, int month);
54 
55  static long hebrew_elapsed_days(int year);
56  static long hebrew_elapsed_days2(int year);
57  static int hebrew_year_length(int year);
58 
59  static void finish_up(long absolute, int hyear, int hmonth,
60  int syear, int smonth,
61  struct DateResult *result);
62 
63  static void SecularToHebrewConversion(int year, int month, int day,
64  struct DateResult *result);
65  static void HebrewToSecularConversion(int year, int month, int day,
66  struct DateResult *result);
67 
68 private:
69 
70  static TQStringList HebrewMonthNames;
71  static TQStringList SecularMonthNames;
72 
73 };
74 
75 #endif