| 1 |
|
/** |
| 2 |
|
Copyright 2002 Cyril Picard |
| 3 |
|
|
| 4 |
|
This file is part of the GEDCOMParser library |
| 5 |
|
(developed within the Genealogy Free Software Tools project). |
| 6 |
|
|
| 7 |
|
The GEDCOMParser library is free software; you can redistribute it and/or modify |
| 8 |
|
it under the terms of the GNU General Public License as published by |
| 9 |
|
the Free Software Foundation; either version 2 of the License, or |
| 10 |
|
(at your option) any later version. |
| 11 |
|
|
| 12 |
|
The GEDCOMParser library is distributed in the hope that it will be useful, |
| 13 |
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
|
GNU General Public License for more details. |
| 16 |
|
|
| 17 |
|
You should have received a copy of the GNU General Public License |
| 18 |
|
along with the GEDCOMParser library ; if not, write to the Free Software |
| 19 |
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 |
|
|
| 21 |
|
**/ |
| 22 |
|
|
| 23 |
|
#include "GEDCOMParser/DateManagement/Date.hh" |
| 24 |
|
|
| 25 |
|
#ifdef HAVE_CONFIG_H |
| 26 |
|
#include "config.h" |
| 27 |
|
#endif // HAVE_CONFIG_H |
| 28 |
|
|
| 29 |
|
#include "gettext.h" |
| 30 |
|
#define _(String) dgettext(PACKAGE, String) |
| 31 |
|
|
| 32 |
|
void GEDCOMParser::DateManagement::Date::setCalendar(enumCalendars cal) |
| 33 |
|
{ |
| 34 |
|
_calendar = cal; |
| 35 |
|
return; |
| 36 |
|
} |
| 37 |
|
|
| 38 |
|
void GEDCOMParser::DateManagement::Date::setDay(std::string const &day) |
| 39 |
|
{ |
| 40 |
|
_day = day; |
| 41 |
|
return; |
| 42 |
|
} |
| 43 |
|
|
| 44 |
|
void GEDCOMParser::DateManagement::Date::setMonth(enumMonths month) |
| 45 |
|
{ |
| 46 |
|
_month = month; |
| 47 |
|
return; |
| 48 |
|
} |
| 49 |
|
|
| 50 |
|
void GEDCOMParser::DateManagement::Date::setYear(std::string const &year) |
| 51 |
|
{ |
| 52 |
|
_year = year; |
| 53 |
|
return; |
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
|
| 57 |
|
void GEDCOMParser::DateManagement::Date::setPrecision(enumPrecisionDateTypes prec) |
| 58 |
|
{ |
| 59 |
|
_precision = prec; |
| 60 |
|
return; |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
void GEDCOMParser::DateManagement::Date::setFrenchYearFormat(enumFrenchYearFormat format) |
| 64 |
|
{ |
| 65 |
|
_french_year_format = format; |
| 66 |
|
return; |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
void GEDCOMParser::DateManagement::Date::setBeforeChrist(bool val) |
| 70 |
|
{ |
| 71 |
|
_before_christ = val; |
| 72 |
|
return; |
| 73 |
|
} |
| 74 |
|
|
| 75 |
|
std::string const GEDCOMParser::DateManagement::Date::getDisplayValue(void) const |
| 76 |
|
{ |
| 77 |
|
std::string res; |
| 78 |
|
std::string month; |
| 79 |
|
std::string year; |
| 80 |
|
std::string precision; |
| 81 |
|
|
| 82 |
|
year = _year; |
| 83 |
|
|
| 84 |
|
switch (_calendar) |
| 85 |
|
{ |
| 86 |
|
case e_French: |
| 87 |
|
{ |
| 88 |
|
if (_french_year_format == e_FrenchYearFormat_Roman) |
| 89 |
|
{ |
| 90 |
|
year = _("AN " ) + year; |
| 91 |
|
} |
| 92 |
|
} |
| 93 |
|
break; |
| 94 |
|
default: |
| 95 |
|
break; |
| 96 |
|
}; |
| 97 |
|
switch(_month) |
| 98 |
|
{ |
| 99 |
|
case e_Jan: |
| 100 |
|
month = _("Jan"); |
| 101 |
|
break; |
| 102 |
|
case e_Feb: |
| 103 |
|
month = _("Feb"); |
| 104 |
|
break; |
| 105 |
|
case e_Mar: |
| 106 |
|
month = _("Mar"); |
| 107 |
|
break; |
| 108 |
|
case e_Apr: |
| 109 |
|
month = _("Apr"); |
| 110 |
|
break; |
| 111 |
|
case e_May: |
| 112 |
|
month = _("May"); |
| 113 |
|
break; |
| 114 |
|
case e_Jun: |
| 115 |
|
month = _("Jun"); |
| 116 |
|
break; |
| 117 |
|
case e_Jul: |
| 118 |
|
month = _("Jul"); |
| 119 |
|
break; |
| 120 |
|
case e_Aug: |
| 121 |
|
month = _("Aug"); |
| 122 |
|
break; |
| 123 |
|
case e_Sep: |
| 124 |
|
month = _("Sep"); |
| 125 |
|
break; |
| 126 |
|
case e_Oct: |
| 127 |
|
month = _("Oct"); |
| 128 |
|
break; |
| 129 |
|
case e_Nov: |
| 130 |
|
month = _("Nov"); |
| 131 |
|
break; |
| 132 |
|
case e_Dec: |
| 133 |
|
month = _("Dec"); |
| 134 |
|
break; |
| 135 |
|
case e_Hebr_Tsh: |
| 136 |
|
month = _("Tsh"); |
| 137 |
|
break; |
| 138 |
|
case e_Hebr_Csh: |
| 139 |
|
month = _("Csh"); |
| 140 |
|
break; |
| 141 |
|
case e_Hebr_Ksl: |
| 142 |
|
month = _("Ksl"); |
| 143 |
|
break; |
| 144 |
|
case e_Hebr_Tvt: |
| 145 |
|
month = _("Tvt"); |
| 146 |
|
break; |
| 147 |
|
case e_Hebr_Shv: |
| 148 |
|
month = _("Shv"); |
| 149 |
|
break; |
| 150 |
|
case e_Hebr_Adr: |
| 151 |
|
month = _("Adr"); |
| 152 |
|
break; |
| 153 |
|
case e_Hebr_Ads: |
| 154 |
|
month = _("Ads"); |
| 155 |
|
break; |
| 156 |
|
case e_Hebr_Nsn: |
| 157 |
|
month = _("Nsn"); |
| 158 |
|
break; |
| 159 |
|
case e_Hebr_Iyr: |
| 160 |
|
month = _("Iyr"); |
| 161 |
|
break; |
| 162 |
|
case e_Hebr_Svn: |
| 163 |
|
month = _("Svn"); |
| 164 |
|
break; |
| 165 |
|
case e_Hebr_Tmz: |
| 166 |
|
month = _("Tmz"); |
| 167 |
|
break; |
| 168 |
|
case e_Hebr_Aav: |
| 169 |
|
month = _("Aav"); |
| 170 |
|
break; |
| 171 |
|
case e_Hebr_Ell: |
| 172 |
|
month = _("Ell"); |
| 173 |
|
break; |
| 174 |
|
case e_Fren_Vend: |
| 175 |
|
month = _("Vend"); |
| 176 |
|
break; |
| 177 |
|
case e_Fren_Brum: |
| 178 |
|
month = _("Brum"); |
| 179 |
|
break; |
| 180 |
|
case e_Fren_Frim: |
| 181 |
|
month = _("Frim"); |
| 182 |
|
break; |
| 183 |
|
case e_Fren_Nivo: |
| 184 |
|
month = _("Nivo"); |
| 185 |
|
break; |
| 186 |
|
case e_Fren_Pluv: |
| 187 |
|
month = _("Pluv"); |
| 188 |
|
break; |
| 189 |
|
case e_Fren_Vent: |
| 190 |
|
month = _("Vent"); |
| 191 |
|
break; |
| 192 |
|
case e_Fren_Germ: |
| 193 |
|
month = _("Germ"); |
| 194 |
|
break; |
| 195 |
|
case e_Fren_Flor: |
| 196 |
|
month = _("Flor"); |
| 197 |
|
break; |
| 198 |
|
case e_Fren_Prai: |
| 199 |
|
month = _("Prai"); |
| 200 |
|
break; |
| 201 |
|
case e_Fren_Mess: |
| 202 |
|
month = _("Mess"); |
| 203 |
|
break; |
| 204 |
|
case e_Fren_Ther: |
| 205 |
|
month = _("Ther"); |
| 206 |
|
break; |
| 207 |
|
case e_Fren_Fruc: |
| 208 |
|
month = _("Fruc"); |
| 209 |
|
break; |
| 210 |
|
case e_Fren_Comp: |
| 211 |
|
month = _("Comp"); |
| 212 |
|
break; |
| 213 |
|
default: |
| 214 |
|
month = ""; |
| 215 |
|
break; |
| 216 |
|
} |
| 217 |
|
|
| 218 |
|
switch(_precision) |
| 219 |
|
{ |
| 220 |
|
case e_About: |
| 221 |
|
precision = _("About "); |
| 222 |
|
break; |
| 223 |
|
case e_Calculated: |
| 224 |
|
precision = _("(calculated) "); |
| 225 |
|
break; |
| 226 |
|
case e_Estimated: |
| 227 |
|
precision = _("(estimated) "); |
| 228 |
|
break; |
| 229 |
|
default: |
| 230 |
|
break; |
| 231 |
|
} |
| 232 |
|
std::string day_month_separator; |
| 233 |
|
std::string month_year_separator; |
| 234 |
|
|
| 235 |
|
if ((_day != "") && (month != "")) |
| 236 |
|
{ |
| 237 |
|
day_month_separator = " "; |
| 238 |
|
} |
| 239 |
|
if ((month != "") && (year != "")) |
| 240 |
|
{ |
| 241 |
|
month_year_separator = " "; |
| 242 |
|
} |
| 243 |
|
|
| 244 |
|
res = precision + _day + day_month_separator + month + month_year_separator + year; |
| 245 |
|
|
| 246 |
|
if (_before_christ == true) |
| 247 |
|
{ |
| 248 |
|
res = res + _(" B.C."); |
| 249 |
|
} |
| 250 |
|
|
| 251 |
|
return res; |
| 252 |
|
} |
| 253 |
|
|