[111] | 1 | // file : xsd/cxx/tree/date-time.ixx |
---|
| 2 | // author : Boris Kolpackov <boris@codesynthesis.com> |
---|
| 3 | // copyright : Copyright (c) 2005-2008 Code Synthesis Tools CC |
---|
| 4 | // license : GNU GPL v2 + exceptions; see accompanying LICENSE file |
---|
| 5 | |
---|
| 6 | namespace xsd |
---|
| 7 | { |
---|
| 8 | namespace cxx |
---|
| 9 | { |
---|
| 10 | namespace tree |
---|
| 11 | { |
---|
| 12 | // time_zone |
---|
| 13 | // |
---|
| 14 | inline time_zone:: |
---|
| 15 | time_zone () |
---|
| 16 | : present_ (false) |
---|
| 17 | { |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | inline time_zone:: |
---|
| 21 | time_zone (short h, short m) |
---|
| 22 | : present_ (true), hours_ (h), minutes_ (m) |
---|
| 23 | { |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | inline bool time_zone:: |
---|
| 27 | zone_present () const |
---|
| 28 | { |
---|
| 29 | return present_; |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | inline void time_zone:: |
---|
| 33 | zone_reset () |
---|
| 34 | { |
---|
| 35 | present_ = false; |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | inline short time_zone:: |
---|
| 39 | zone_hours () const |
---|
| 40 | { |
---|
| 41 | return hours_; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | inline void time_zone:: |
---|
| 45 | zone_hours (short h) |
---|
| 46 | { |
---|
| 47 | hours_ = h; |
---|
| 48 | present_ = true; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | inline short time_zone:: |
---|
| 52 | zone_minutes () const |
---|
| 53 | { |
---|
| 54 | return minutes_; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | inline void time_zone:: |
---|
| 58 | zone_minutes (short m) |
---|
| 59 | { |
---|
| 60 | minutes_ = m; |
---|
| 61 | present_ = true; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | inline bool |
---|
| 65 | operator== (const time_zone& x, const time_zone& y) |
---|
| 66 | { |
---|
| 67 | return x.zone_present () |
---|
| 68 | ? y.zone_present () && |
---|
| 69 | x.zone_hours () == y.zone_hours () && |
---|
| 70 | x.zone_minutes () == y.zone_minutes () |
---|
| 71 | : !y.zone_present (); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | inline bool |
---|
| 75 | operator!= (const time_zone& x, const time_zone& y) |
---|
| 76 | { |
---|
| 77 | return !(x == y); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | // gday |
---|
| 81 | // |
---|
| 82 | template <typename C, typename B> |
---|
| 83 | inline gday<C, B>:: |
---|
| 84 | gday () |
---|
| 85 | { |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | template <typename C, typename B> |
---|
| 89 | inline gday<C, B>:: |
---|
| 90 | gday (unsigned short day) |
---|
| 91 | : day_ (day) |
---|
| 92 | { |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | template <typename C, typename B> |
---|
| 96 | inline gday<C, B>:: |
---|
| 97 | gday (unsigned short day, short zone_h, short zone_m) |
---|
| 98 | : time_zone (zone_h, zone_m), day_ (day) |
---|
| 99 | { |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | template <typename C, typename B> |
---|
| 103 | inline gday<C, B>:: |
---|
| 104 | gday (const gday& x, flags f, container* c) |
---|
| 105 | : B (x, f, c), time_zone (x), day_ (x.day_) |
---|
| 106 | { |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | template <typename C, typename B> |
---|
| 110 | inline unsigned short gday<C, B>:: |
---|
| 111 | day () const |
---|
| 112 | { |
---|
| 113 | return day_; |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | template <typename C, typename B> |
---|
| 117 | inline void gday<C, B>:: |
---|
| 118 | day (unsigned short day) |
---|
| 119 | { |
---|
| 120 | day_ = day; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | template <typename C, typename B> |
---|
| 124 | inline bool |
---|
| 125 | operator== (const gday<C, B>& x, const gday<C, B>& y) |
---|
| 126 | { |
---|
| 127 | const time_zone& xz = x; |
---|
| 128 | const time_zone& yz = y; |
---|
| 129 | |
---|
| 130 | return x.day () == y.day () && xz == yz; |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | template <typename C, typename B> |
---|
| 134 | inline bool |
---|
| 135 | operator!= (const gday<C, B>& x, const gday<C, B>& y) |
---|
| 136 | { |
---|
| 137 | return !(x == y); |
---|
| 138 | } |
---|
| 139 | |
---|
| 140 | // gmonth |
---|
| 141 | // |
---|
| 142 | template <typename C, typename B> |
---|
| 143 | inline gmonth<C, B>:: |
---|
| 144 | gmonth () |
---|
| 145 | { |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | template <typename C, typename B> |
---|
| 149 | inline gmonth<C, B>:: |
---|
| 150 | gmonth (unsigned short month) |
---|
| 151 | : month_ (month) |
---|
| 152 | { |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | template <typename C, typename B> |
---|
| 156 | inline gmonth<C, B>:: |
---|
| 157 | gmonth (unsigned short month, short zone_h, short zone_m) |
---|
| 158 | : time_zone (zone_h, zone_m), month_ (month) |
---|
| 159 | { |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | template <typename C, typename B> |
---|
| 163 | inline gmonth<C, B>:: |
---|
| 164 | gmonth (const gmonth& x, flags f, container* c) |
---|
| 165 | : B (x, f, c), time_zone (x), month_ (x.month_) |
---|
| 166 | { |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | template <typename C, typename B> |
---|
| 170 | inline unsigned short gmonth<C, B>:: |
---|
| 171 | month () const |
---|
| 172 | { |
---|
| 173 | return month_; |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | template <typename C, typename B> |
---|
| 177 | inline void gmonth<C, B>:: |
---|
| 178 | month (unsigned short month) |
---|
| 179 | { |
---|
| 180 | month_ = month; |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | template <typename C, typename B> |
---|
| 184 | inline bool |
---|
| 185 | operator== (const gmonth<C, B>& x, const gmonth<C, B>& y) |
---|
| 186 | { |
---|
| 187 | const time_zone& xz = x; |
---|
| 188 | const time_zone& yz = y; |
---|
| 189 | |
---|
| 190 | return x.month () == y.month () && xz == yz; |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | template <typename C, typename B> |
---|
| 194 | inline bool |
---|
| 195 | operator!= (const gmonth<C, B>& x, const gmonth<C, B>& y) |
---|
| 196 | { |
---|
| 197 | return !(x == y); |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | // gyear |
---|
| 201 | // |
---|
| 202 | template <typename C, typename B> |
---|
| 203 | inline gyear<C, B>:: |
---|
| 204 | gyear () |
---|
| 205 | { |
---|
| 206 | } |
---|
| 207 | |
---|
| 208 | template <typename C, typename B> |
---|
| 209 | inline gyear<C, B>:: |
---|
| 210 | gyear (int year) |
---|
| 211 | : year_ (year) |
---|
| 212 | { |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | template <typename C, typename B> |
---|
| 216 | inline gyear<C, B>:: |
---|
| 217 | gyear (int year, short zone_h, short zone_m) |
---|
| 218 | : time_zone (zone_h, zone_m), year_ (year) |
---|
| 219 | { |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | template <typename C, typename B> |
---|
| 223 | inline gyear<C, B>:: |
---|
| 224 | gyear (const gyear& x, flags f, container* c) |
---|
| 225 | : B (x, f, c), time_zone (x), year_ (x.year_) |
---|
| 226 | { |
---|
| 227 | } |
---|
| 228 | |
---|
| 229 | template <typename C, typename B> |
---|
| 230 | inline int gyear<C, B>:: |
---|
| 231 | year () const |
---|
| 232 | { |
---|
| 233 | return year_; |
---|
| 234 | } |
---|
| 235 | |
---|
| 236 | template <typename C, typename B> |
---|
| 237 | inline void gyear<C, B>:: |
---|
| 238 | year (int year) |
---|
| 239 | { |
---|
| 240 | year_ = year; |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | template <typename C, typename B> |
---|
| 244 | inline bool |
---|
| 245 | operator== (const gyear<C, B>& x, const gyear<C, B>& y) |
---|
| 246 | { |
---|
| 247 | const time_zone& xz = x; |
---|
| 248 | const time_zone& yz = y; |
---|
| 249 | |
---|
| 250 | return x.year () == y.year () && xz == yz; |
---|
| 251 | } |
---|
| 252 | |
---|
| 253 | template <typename C, typename B> |
---|
| 254 | inline bool |
---|
| 255 | operator!= (const gyear<C, B>& x, const gyear<C, B>& y) |
---|
| 256 | { |
---|
| 257 | return !(x == y); |
---|
| 258 | } |
---|
| 259 | |
---|
| 260 | // gmonth_day |
---|
| 261 | // |
---|
| 262 | template <typename C, typename B> |
---|
| 263 | inline gmonth_day<C, B>:: |
---|
| 264 | gmonth_day () |
---|
| 265 | { |
---|
| 266 | } |
---|
| 267 | |
---|
| 268 | template <typename C, typename B> |
---|
| 269 | inline gmonth_day<C, B>:: |
---|
| 270 | gmonth_day (unsigned short month, unsigned short day) |
---|
| 271 | : month_ (month), day_ (day) |
---|
| 272 | { |
---|
| 273 | } |
---|
| 274 | |
---|
| 275 | template <typename C, typename B> |
---|
| 276 | inline gmonth_day<C, B>:: |
---|
| 277 | gmonth_day (unsigned short month, unsigned short day, |
---|
| 278 | short zone_h, short zone_m) |
---|
| 279 | : time_zone (zone_h, zone_m), month_ (month), day_ (day) |
---|
| 280 | { |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | template <typename C, typename B> |
---|
| 284 | inline gmonth_day<C, B>:: |
---|
| 285 | gmonth_day (const gmonth_day& x, flags f, container* c) |
---|
| 286 | : B (x, f, c), time_zone (x), month_ (x.month_), day_ (x.day_) |
---|
| 287 | { |
---|
| 288 | } |
---|
| 289 | |
---|
| 290 | template <typename C, typename B> |
---|
| 291 | inline unsigned short gmonth_day<C, B>:: |
---|
| 292 | month () const |
---|
| 293 | { |
---|
| 294 | return month_; |
---|
| 295 | } |
---|
| 296 | |
---|
| 297 | template <typename C, typename B> |
---|
| 298 | inline void gmonth_day<C, B>:: |
---|
| 299 | month (unsigned short month) |
---|
| 300 | { |
---|
| 301 | month_ = month; |
---|
| 302 | } |
---|
| 303 | |
---|
| 304 | template <typename C, typename B> |
---|
| 305 | inline unsigned short gmonth_day<C, B>:: |
---|
| 306 | day () const |
---|
| 307 | { |
---|
| 308 | return day_; |
---|
| 309 | } |
---|
| 310 | |
---|
| 311 | template <typename C, typename B> |
---|
| 312 | inline void gmonth_day<C, B>:: |
---|
| 313 | day (unsigned short day) |
---|
| 314 | { |
---|
| 315 | day_ = day; |
---|
| 316 | } |
---|
| 317 | |
---|
| 318 | template <typename C, typename B> |
---|
| 319 | inline bool |
---|
| 320 | operator== (const gmonth_day<C, B>& x, const gmonth_day<C, B>& y) |
---|
| 321 | { |
---|
| 322 | const time_zone& xz = x; |
---|
| 323 | const time_zone& yz = y; |
---|
| 324 | |
---|
| 325 | return x.month () == y.month () && |
---|
| 326 | x.day () == y.day () && |
---|
| 327 | xz == yz; |
---|
| 328 | } |
---|
| 329 | |
---|
| 330 | template <typename C, typename B> |
---|
| 331 | inline bool |
---|
| 332 | operator!= (const gmonth_day<C, B>& x, const gmonth_day<C, B>& y) |
---|
| 333 | { |
---|
| 334 | return !(x == y); |
---|
| 335 | } |
---|
| 336 | |
---|
| 337 | // gyear_month |
---|
| 338 | // |
---|
| 339 | template <typename C, typename B> |
---|
| 340 | inline gyear_month<C, B>:: |
---|
| 341 | gyear_month () |
---|
| 342 | { |
---|
| 343 | } |
---|
| 344 | |
---|
| 345 | template <typename C, typename B> |
---|
| 346 | inline gyear_month<C, B>:: |
---|
| 347 | gyear_month (int year, unsigned short month) |
---|
| 348 | : year_ (year), month_ (month) |
---|
| 349 | { |
---|
| 350 | } |
---|
| 351 | |
---|
| 352 | template <typename C, typename B> |
---|
| 353 | inline gyear_month<C, B>:: |
---|
| 354 | gyear_month (int year, unsigned short month, |
---|
| 355 | short zone_h, short zone_m) |
---|
| 356 | : time_zone (zone_h, zone_m), year_ (year), month_ (month) |
---|
| 357 | { |
---|
| 358 | } |
---|
| 359 | |
---|
| 360 | template <typename C, typename B> |
---|
| 361 | inline gyear_month<C, B>:: |
---|
| 362 | gyear_month (const gyear_month& x, flags f, container* c) |
---|
| 363 | : B (x, f, c), time_zone (x), year_ (x.year_), month_ (x.month_) |
---|
| 364 | { |
---|
| 365 | } |
---|
| 366 | |
---|
| 367 | template <typename C, typename B> |
---|
| 368 | inline int gyear_month<C, B>:: |
---|
| 369 | year () const |
---|
| 370 | { |
---|
| 371 | return year_; |
---|
| 372 | } |
---|
| 373 | |
---|
| 374 | template <typename C, typename B> |
---|
| 375 | inline void gyear_month<C, B>:: |
---|
| 376 | year (int year) |
---|
| 377 | { |
---|
| 378 | year_ = year; |
---|
| 379 | } |
---|
| 380 | |
---|
| 381 | template <typename C, typename B> |
---|
| 382 | inline unsigned short gyear_month<C, B>:: |
---|
| 383 | month () const |
---|
| 384 | { |
---|
| 385 | return month_; |
---|
| 386 | } |
---|
| 387 | |
---|
| 388 | template <typename C, typename B> |
---|
| 389 | inline void gyear_month<C, B>:: |
---|
| 390 | month (unsigned short month) |
---|
| 391 | { |
---|
| 392 | month_ = month; |
---|
| 393 | } |
---|
| 394 | |
---|
| 395 | template <typename C, typename B> |
---|
| 396 | inline bool |
---|
| 397 | operator== (const gyear_month<C, B>& x, const gyear_month<C, B>& y) |
---|
| 398 | { |
---|
| 399 | const time_zone& xz = x; |
---|
| 400 | const time_zone& yz = y; |
---|
| 401 | |
---|
| 402 | return x.year () == y.year () && |
---|
| 403 | x.month () == y.month () && |
---|
| 404 | xz == yz; |
---|
| 405 | } |
---|
| 406 | |
---|
| 407 | template <typename C, typename B> |
---|
| 408 | inline bool |
---|
| 409 | operator!= (const gyear_month<C, B>& x, const gyear_month<C, B>& y) |
---|
| 410 | { |
---|
| 411 | return !(x == y); |
---|
| 412 | } |
---|
| 413 | |
---|
| 414 | // date |
---|
| 415 | // |
---|
| 416 | template <typename C, typename B> |
---|
| 417 | inline date<C, B>:: |
---|
| 418 | date () |
---|
| 419 | { |
---|
| 420 | } |
---|
| 421 | |
---|
| 422 | template <typename C, typename B> |
---|
| 423 | inline date<C, B>:: |
---|
| 424 | date (int year, unsigned short month, unsigned short day) |
---|
| 425 | : year_ (year), month_ (month), day_ (day) |
---|
| 426 | { |
---|
| 427 | } |
---|
| 428 | |
---|
| 429 | template <typename C, typename B> |
---|
| 430 | inline date<C, B>:: |
---|
| 431 | date (int year, unsigned short month, unsigned short day, |
---|
| 432 | short zone_h, short zone_m) |
---|
| 433 | : time_zone (zone_h, zone_m), |
---|
| 434 | year_ (year), month_ (month), day_ (day) |
---|
| 435 | { |
---|
| 436 | } |
---|
| 437 | |
---|
| 438 | template <typename C, typename B> |
---|
| 439 | inline date<C, B>:: |
---|
| 440 | date (const date& x, flags f, container* c) |
---|
| 441 | : B (x, f, c), time_zone (x), |
---|
| 442 | year_ (x.year_), month_ (x.month_), day_ (x.day_) |
---|
| 443 | { |
---|
| 444 | } |
---|
| 445 | |
---|
| 446 | template <typename C, typename B> |
---|
| 447 | inline int date<C, B>:: |
---|
| 448 | year () const |
---|
| 449 | { |
---|
| 450 | return year_; |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | template <typename C, typename B> |
---|
| 454 | inline void date<C, B>:: |
---|
| 455 | year (int year) |
---|
| 456 | { |
---|
| 457 | year_ = year; |
---|
| 458 | } |
---|
| 459 | |
---|
| 460 | template <typename C, typename B> |
---|
| 461 | inline unsigned short date<C, B>:: |
---|
| 462 | month () const |
---|
| 463 | { |
---|
| 464 | return month_; |
---|
| 465 | } |
---|
| 466 | |
---|
| 467 | template <typename C, typename B> |
---|
| 468 | inline void date<C, B>:: |
---|
| 469 | month (unsigned short month) |
---|
| 470 | { |
---|
| 471 | month_ = month; |
---|
| 472 | } |
---|
| 473 | |
---|
| 474 | template <typename C, typename B> |
---|
| 475 | inline unsigned short date<C, B>:: |
---|
| 476 | day () const |
---|
| 477 | { |
---|
| 478 | return day_; |
---|
| 479 | } |
---|
| 480 | |
---|
| 481 | template <typename C, typename B> |
---|
| 482 | inline void date<C, B>:: |
---|
| 483 | day (unsigned short day) |
---|
| 484 | { |
---|
| 485 | day_ = day; |
---|
| 486 | } |
---|
| 487 | |
---|
| 488 | template <typename C, typename B> |
---|
| 489 | inline bool |
---|
| 490 | operator== (const date<C, B>& x, const date<C, B>& y) |
---|
| 491 | { |
---|
| 492 | const time_zone& xz = x; |
---|
| 493 | const time_zone& yz = y; |
---|
| 494 | |
---|
| 495 | return x.year () == y.year () && |
---|
| 496 | x.month () == y.month () && |
---|
| 497 | x.day () == y.day () && |
---|
| 498 | xz == yz; |
---|
| 499 | } |
---|
| 500 | |
---|
| 501 | template <typename C, typename B> |
---|
| 502 | inline bool |
---|
| 503 | operator!= (const date<C, B>& x, const date<C, B>& y) |
---|
| 504 | { |
---|
| 505 | return !(x == y); |
---|
| 506 | } |
---|
| 507 | |
---|
| 508 | // time |
---|
| 509 | // |
---|
| 510 | template <typename C, typename B> |
---|
| 511 | inline time<C, B>:: |
---|
| 512 | time () |
---|
| 513 | { |
---|
| 514 | } |
---|
| 515 | |
---|
| 516 | template <typename C, typename B> |
---|
| 517 | inline time<C, B>:: |
---|
| 518 | time (unsigned short hours, unsigned short minutes, double seconds) |
---|
| 519 | : hours_ (hours), minutes_ (minutes), seconds_ (seconds) |
---|
| 520 | { |
---|
| 521 | } |
---|
| 522 | |
---|
| 523 | template <typename C, typename B> |
---|
| 524 | inline time<C, B>:: |
---|
| 525 | time (unsigned short hours, unsigned short minutes, double seconds, |
---|
| 526 | short zone_h, short zone_m) |
---|
| 527 | : time_zone (zone_h, zone_m), |
---|
| 528 | hours_ (hours), minutes_ (minutes), seconds_ (seconds) |
---|
| 529 | { |
---|
| 530 | } |
---|
| 531 | |
---|
| 532 | template <typename C, typename B> |
---|
| 533 | inline time<C, B>:: |
---|
| 534 | time (const time& x, flags f, container* c) |
---|
| 535 | : B (x, f, c), time_zone (x), |
---|
| 536 | hours_ (x.hours_), minutes_ (x.minutes_), seconds_ (x.seconds_) |
---|
| 537 | { |
---|
| 538 | } |
---|
| 539 | |
---|
| 540 | template <typename C, typename B> |
---|
| 541 | inline unsigned short time<C, B>:: |
---|
| 542 | hours () const |
---|
| 543 | { |
---|
| 544 | return hours_; |
---|
| 545 | } |
---|
| 546 | |
---|
| 547 | template <typename C, typename B> |
---|
| 548 | inline void time<C, B>:: |
---|
| 549 | hours (unsigned short hours) |
---|
| 550 | { |
---|
| 551 | hours_ = hours; |
---|
| 552 | } |
---|
| 553 | |
---|
| 554 | template <typename C, typename B> |
---|
| 555 | inline unsigned short time<C, B>:: |
---|
| 556 | minutes () const |
---|
| 557 | { |
---|
| 558 | return minutes_; |
---|
| 559 | } |
---|
| 560 | |
---|
| 561 | template <typename C, typename B> |
---|
| 562 | inline void time<C, B>:: |
---|
| 563 | minutes (unsigned short minutes) |
---|
| 564 | { |
---|
| 565 | minutes_ = minutes; |
---|
| 566 | } |
---|
| 567 | |
---|
| 568 | template <typename C, typename B> |
---|
| 569 | inline double time<C, B>:: |
---|
| 570 | seconds () const |
---|
| 571 | { |
---|
| 572 | return seconds_; |
---|
| 573 | } |
---|
| 574 | |
---|
| 575 | template <typename C, typename B> |
---|
| 576 | inline void time<C, B>:: |
---|
| 577 | seconds (double seconds) |
---|
| 578 | { |
---|
| 579 | seconds_ = seconds; |
---|
| 580 | } |
---|
| 581 | |
---|
| 582 | template <typename C, typename B> |
---|
| 583 | inline bool |
---|
| 584 | operator== (const time<C, B>& x, const time<C, B>& y) |
---|
| 585 | { |
---|
| 586 | const time_zone& xz = x; |
---|
| 587 | const time_zone& yz = y; |
---|
| 588 | |
---|
| 589 | return x.hours () == y.hours () && |
---|
| 590 | x.minutes () == y.minutes () && |
---|
| 591 | x.seconds () == y.seconds () && |
---|
| 592 | xz == yz; |
---|
| 593 | } |
---|
| 594 | |
---|
| 595 | template <typename C, typename B> |
---|
| 596 | inline bool |
---|
| 597 | operator!= (const time<C, B>& x, const time<C, B>& y) |
---|
| 598 | { |
---|
| 599 | return !(x == y); |
---|
| 600 | } |
---|
| 601 | |
---|
| 602 | // date_time |
---|
| 603 | // |
---|
| 604 | template <typename C, typename B> |
---|
| 605 | inline date_time<C, B>:: |
---|
| 606 | date_time () |
---|
| 607 | { |
---|
| 608 | } |
---|
| 609 | |
---|
| 610 | template <typename C, typename B> |
---|
| 611 | inline date_time<C, B>:: |
---|
| 612 | date_time (int year, unsigned short month, unsigned short day, |
---|
| 613 | unsigned short hours, unsigned short minutes, double seconds) |
---|
| 614 | : year_ (year), month_ (month), day_ (day), |
---|
| 615 | hours_ (hours), minutes_ (minutes), seconds_ (seconds) |
---|
| 616 | { |
---|
| 617 | } |
---|
| 618 | |
---|
| 619 | template <typename C, typename B> |
---|
| 620 | inline date_time<C, B>:: |
---|
| 621 | date_time (int year, unsigned short month, unsigned short day, |
---|
| 622 | unsigned short hours, unsigned short minutes, double seconds, |
---|
| 623 | short zone_h, short zone_m) |
---|
| 624 | : time_zone (zone_h, zone_m), |
---|
| 625 | year_ (year), month_ (month), day_ (day), |
---|
| 626 | hours_ (hours), minutes_ (minutes), seconds_ (seconds) |
---|
| 627 | { |
---|
| 628 | } |
---|
| 629 | |
---|
| 630 | template <typename C, typename B> |
---|
| 631 | inline date_time<C, B>:: |
---|
| 632 | date_time (const date_time& x, flags f, container* c) |
---|
| 633 | : B (x, f, c), time_zone (x), |
---|
| 634 | year_ (x.year_), month_ (x.month_), day_ (x.day_), |
---|
| 635 | hours_ (x.hours_), minutes_ (x.minutes_), seconds_ (x.seconds_) |
---|
| 636 | { |
---|
| 637 | } |
---|
| 638 | |
---|
| 639 | template <typename C, typename B> |
---|
| 640 | inline int date_time<C, B>:: |
---|
| 641 | year () const |
---|
| 642 | { |
---|
| 643 | return year_; |
---|
| 644 | } |
---|
| 645 | |
---|
| 646 | template <typename C, typename B> |
---|
| 647 | inline void date_time<C, B>:: |
---|
| 648 | year (int year) |
---|
| 649 | { |
---|
| 650 | year_ = year; |
---|
| 651 | } |
---|
| 652 | |
---|
| 653 | template <typename C, typename B> |
---|
| 654 | inline unsigned short date_time<C, B>:: |
---|
| 655 | month () const |
---|
| 656 | { |
---|
| 657 | return month_; |
---|
| 658 | } |
---|
| 659 | |
---|
| 660 | template <typename C, typename B> |
---|
| 661 | inline void date_time<C, B>:: |
---|
| 662 | month (unsigned short month) |
---|
| 663 | { |
---|
| 664 | month_ = month; |
---|
| 665 | } |
---|
| 666 | |
---|
| 667 | template <typename C, typename B> |
---|
| 668 | inline unsigned short date_time<C, B>:: |
---|
| 669 | day () const |
---|
| 670 | { |
---|
| 671 | return day_; |
---|
| 672 | } |
---|
| 673 | |
---|
| 674 | template <typename C, typename B> |
---|
| 675 | inline void date_time<C, B>:: |
---|
| 676 | day (unsigned short day) |
---|
| 677 | { |
---|
| 678 | day_ = day; |
---|
| 679 | } |
---|
| 680 | |
---|
| 681 | template <typename C, typename B> |
---|
| 682 | inline unsigned short date_time<C, B>:: |
---|
| 683 | hours () const |
---|
| 684 | { |
---|
| 685 | return hours_; |
---|
| 686 | } |
---|
| 687 | |
---|
| 688 | template <typename C, typename B> |
---|
| 689 | inline void date_time<C, B>:: |
---|
| 690 | hours (unsigned short hours) |
---|
| 691 | { |
---|
| 692 | hours_ = hours; |
---|
| 693 | } |
---|
| 694 | |
---|
| 695 | template <typename C, typename B> |
---|
| 696 | inline unsigned short date_time<C, B>:: |
---|
| 697 | minutes () const |
---|
| 698 | { |
---|
| 699 | return minutes_; |
---|
| 700 | } |
---|
| 701 | |
---|
| 702 | template <typename C, typename B> |
---|
| 703 | inline void date_time<C, B>:: |
---|
| 704 | minutes (unsigned short minutes) |
---|
| 705 | { |
---|
| 706 | minutes_ = minutes; |
---|
| 707 | } |
---|
| 708 | |
---|
| 709 | template <typename C, typename B> |
---|
| 710 | inline double date_time<C, B>:: |
---|
| 711 | seconds () const |
---|
| 712 | { |
---|
| 713 | return seconds_; |
---|
| 714 | } |
---|
| 715 | |
---|
| 716 | template <typename C, typename B> |
---|
| 717 | inline void date_time<C, B>:: |
---|
| 718 | seconds (double seconds) |
---|
| 719 | { |
---|
| 720 | seconds_ = seconds; |
---|
| 721 | } |
---|
| 722 | |
---|
| 723 | template <typename C, typename B> |
---|
| 724 | inline bool |
---|
| 725 | operator== (const date_time<C, B>& x, const date_time<C, B>& y) |
---|
| 726 | { |
---|
| 727 | const time_zone& xz = x; |
---|
| 728 | const time_zone& yz = y; |
---|
| 729 | |
---|
| 730 | return x.year () == y.year () && |
---|
| 731 | x.month () == y.month () && |
---|
| 732 | x.day () == y.day () && |
---|
| 733 | x.hours () == y.hours () && |
---|
| 734 | x.minutes () == y.minutes () && |
---|
| 735 | x.seconds () == y.seconds () && |
---|
| 736 | xz == yz; |
---|
| 737 | } |
---|
| 738 | |
---|
| 739 | template <typename C, typename B> |
---|
| 740 | inline bool |
---|
| 741 | operator!= (const date_time<C, B>& x, const date_time<C, B>& y) |
---|
| 742 | { |
---|
| 743 | return !(x == y); |
---|
| 744 | } |
---|
| 745 | |
---|
| 746 | // duration |
---|
| 747 | // |
---|
| 748 | template <typename C, typename B> |
---|
| 749 | inline duration<C, B>:: |
---|
| 750 | duration () |
---|
| 751 | { |
---|
| 752 | } |
---|
| 753 | |
---|
| 754 | template <typename C, typename B> |
---|
| 755 | inline duration<C, B>:: |
---|
| 756 | duration (bool negative, |
---|
| 757 | unsigned int years, unsigned int months, unsigned int days, |
---|
| 758 | unsigned int hours, unsigned int minutes, double seconds) |
---|
| 759 | : negative_ (negative), |
---|
| 760 | years_ (years), months_ (months), days_ (days), |
---|
| 761 | hours_ (hours), minutes_ (minutes), seconds_ (seconds) |
---|
| 762 | { |
---|
| 763 | } |
---|
| 764 | |
---|
| 765 | template <typename C, typename B> |
---|
| 766 | inline duration<C, B>:: |
---|
| 767 | duration (const duration& x, flags f, container* c) |
---|
| 768 | : B (x, f, c), negative_ (x.negative_), |
---|
| 769 | years_ (x.years_), months_ (x.months_), days_ (x.days_), |
---|
| 770 | hours_ (x.hours_), minutes_ (x.minutes_), seconds_ (x.seconds_) |
---|
| 771 | { |
---|
| 772 | } |
---|
| 773 | |
---|
| 774 | template <typename C, typename B> |
---|
| 775 | inline bool duration<C, B>:: |
---|
| 776 | negative () const |
---|
| 777 | { |
---|
| 778 | return negative_; |
---|
| 779 | } |
---|
| 780 | |
---|
| 781 | template <typename C, typename B> |
---|
| 782 | inline void duration<C, B>:: |
---|
| 783 | negative (bool negative) |
---|
| 784 | { |
---|
| 785 | negative_ = negative; |
---|
| 786 | } |
---|
| 787 | |
---|
| 788 | template <typename C, typename B> |
---|
| 789 | inline unsigned int duration<C, B>:: |
---|
| 790 | years () const |
---|
| 791 | { |
---|
| 792 | return years_; |
---|
| 793 | } |
---|
| 794 | |
---|
| 795 | template <typename C, typename B> |
---|
| 796 | inline void duration<C, B>:: |
---|
| 797 | years (unsigned int years) |
---|
| 798 | { |
---|
| 799 | years_ = years; |
---|
| 800 | } |
---|
| 801 | |
---|
| 802 | template <typename C, typename B> |
---|
| 803 | inline unsigned int duration<C, B>:: |
---|
| 804 | months () const |
---|
| 805 | { |
---|
| 806 | return months_; |
---|
| 807 | } |
---|
| 808 | |
---|
| 809 | template <typename C, typename B> |
---|
| 810 | inline void duration<C, B>:: |
---|
| 811 | months (unsigned int months) |
---|
| 812 | { |
---|
| 813 | months_ = months; |
---|
| 814 | } |
---|
| 815 | |
---|
| 816 | template <typename C, typename B> |
---|
| 817 | inline unsigned int duration<C, B>:: |
---|
| 818 | days () const |
---|
| 819 | { |
---|
| 820 | return days_; |
---|
| 821 | } |
---|
| 822 | |
---|
| 823 | template <typename C, typename B> |
---|
| 824 | inline void duration<C, B>:: |
---|
| 825 | days (unsigned int days) |
---|
| 826 | { |
---|
| 827 | days_ = days; |
---|
| 828 | } |
---|
| 829 | |
---|
| 830 | template <typename C, typename B> |
---|
| 831 | inline unsigned int duration<C, B>:: |
---|
| 832 | hours () const |
---|
| 833 | { |
---|
| 834 | return hours_; |
---|
| 835 | } |
---|
| 836 | |
---|
| 837 | template <typename C, typename B> |
---|
| 838 | inline void duration<C, B>:: |
---|
| 839 | hours (unsigned int hours) |
---|
| 840 | { |
---|
| 841 | hours_ = hours; |
---|
| 842 | } |
---|
| 843 | |
---|
| 844 | template <typename C, typename B> |
---|
| 845 | inline unsigned int duration<C, B>:: |
---|
| 846 | minutes () const |
---|
| 847 | { |
---|
| 848 | return minutes_; |
---|
| 849 | } |
---|
| 850 | |
---|
| 851 | template <typename C, typename B> |
---|
| 852 | inline void duration<C, B>:: |
---|
| 853 | minutes (unsigned int minutes) |
---|
| 854 | { |
---|
| 855 | minutes_ = minutes; |
---|
| 856 | } |
---|
| 857 | |
---|
| 858 | template <typename C, typename B> |
---|
| 859 | inline double duration<C, B>:: |
---|
| 860 | seconds () const |
---|
| 861 | { |
---|
| 862 | return seconds_; |
---|
| 863 | } |
---|
| 864 | |
---|
| 865 | template <typename C, typename B> |
---|
| 866 | inline void duration<C, B>:: |
---|
| 867 | seconds (double seconds) |
---|
| 868 | { |
---|
| 869 | seconds_ = seconds; |
---|
| 870 | } |
---|
| 871 | |
---|
| 872 | template <typename C, typename B> |
---|
| 873 | inline bool |
---|
| 874 | operator== (const duration<C, B>& x, const duration<C, B>& y) |
---|
| 875 | { |
---|
| 876 | return x.negative () == y.negative () && |
---|
| 877 | x.years () == y.years () && |
---|
| 878 | x.months () == y.months () && |
---|
| 879 | x.days () == y.days () && |
---|
| 880 | x.hours () == y.hours () && |
---|
| 881 | x.minutes () == y.minutes () && |
---|
| 882 | x.seconds () == y.seconds (); |
---|
| 883 | } |
---|
| 884 | |
---|
| 885 | template <typename C, typename B> |
---|
| 886 | inline bool |
---|
| 887 | operator!= (const duration<C, B>& x, const duration<C, B>& y) |
---|
| 888 | { |
---|
| 889 | return !(x == y); |
---|
| 890 | } |
---|
| 891 | } |
---|
| 892 | } |
---|
| 893 | } |
---|