/usr/include/ucommon/datetime.h is in libucommon-dev 3.2.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 | // Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
//
// This file is part of GNU uCommon C++.
//
// GNU uCommon C++ is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU uCommon C++ is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.
/**
* Basic classes for manipulating time and date based data, particularly
* that may be in strings.
* @file ucommon/datetime.h
*/
/**
* Example of date & time manipulation.
* @example datetime.cpp
*/
#ifndef _UCOMMON_DATETIME_H_
#define _UCOMMON_DATETIME_H_
#ifndef _UCOMMON_CONFIG_H_
#include <ucommon/platform.h>
#endif
#ifndef _UCOMMON_NUMBERS_H_
#include <ucommon/numbers.h>
#endif
#ifndef _UCOMMON_STRING_H_
#include <ucommon/string.h>
#endif
#define DATE_STRING_SIZE 10
#define DATE_BUFFER_SIZE 11
#define TIME_STRING_SIZE 8
#define TIME_BUFFER_SIZE 9
#define DATETIME_STRING_SIZE 19
#define DATETIME_BUFFER_SIZE 20
NAMESPACE_UCOMMON
#ifdef __BORLANDC__
using std::tm;
using std::time_t;
#endif
/**
* The Date class uses a julian date representation of the current
* year, month, and day. This is then manipulated in several forms
* and may be exported as needed.
*
* @author David Sugar <dyfet@ostel.com>
* @short julian number based date class.
*/
class __EXPORT Date
{
protected:
long julian;
void toJulian(long year, long month, long day);
void fromJulian(char *buf) const;
/**
* A method to use to "post" any changed values when shadowing
* a mixed object class. This is used by DateNumber and string classes.
*/
virtual void update(void);
public:
/**
* index elements.
*/
typedef enum {year = 10, month, day, dow} index_t;
/**
* Size of date string field.
*/
static const size_t sz_string;
/**
* Create a julian date from a time_t type.
* @param value from time()
*/
Date(time_t value);
/**
* Create a julian date from a local or gmt date and time.
* @param object from DateTime::glt() or gmt().
*/
Date(struct tm *object);
/**
* Create a julian date from a ISO date string of a specified size.
* @param pointer to ISO date string.
* @param size of date field if not null terminated.
*/
Date(const char *pointer, size_t size = 0);
/**
* Create a julian date from an arbitrary year, month, and day.
* @param year of date.
* @param month of date (1-12).
* @param day of month (1-31).
*/
Date(int year, unsigned month = 1, unsigned day = 1);
/**
* Create a julian date object from another object.
* @param object to copy.
*/
Date(const Date& object);
/**
* Construct a new julian date with today's date.
*/
Date();
/**
* Destroy julian date object.
*/
virtual ~Date();
/**
* Get the year of the date.
* @return year of the date
*/
int getYear(void) const;
/**
* Get the month of the date (1-12).
* @return month of year
*/
unsigned getMonth(void) const;
/**
* Get the day of the month of the date.
* @return day of month
*/
unsigned getDay(void) const;
/**
* Get the day of the week (0-7).
* @return day of week
*/
unsigned getDayOfWeek(void) const;
/**
* Get the julian number of a date.
* @return julian number.
*/
inline long getJulian(void)
{return julian;};
/**
* Get a ISO string representation of the date (yyyy-mm-dd).
* @param buffer to store string.
* @return string representation.
*/
char *get(char *buffer) const;
/**
* Get a time_t for the julian date if in time_t epoch.
* @return time_t or -1 if out of range.
*/
time_t getTime(void) const;
/**
* Get the date as a number for the object or 0 if invalid.
* @return date as number.
*/
long get(void) const;
/**
* Set (update) the date with current date.
*/
void set(void);
/**
* Set the julian date based on an ISO date string of specified size.
* @param pointer to date string field.
* @param size of field if not null terminated.
*/
void set(const char *pointer, size_t size = 0);
/**
* Check if date is valid.
* @return true if julian date is valid.
*/
bool isValid(void) const;
/**
* Casting operator to return date as number.
* @return julian number.
*/
inline operator long() const
{return get();};
/**
* Access numeric components.
* @param component to access.
* @return value of component.
*/
int operator[](index_t component) const;
/**
* Access julian value.
* @return julian number of object.
*/
inline long operator*() const
{return get();};
/**
* Expression operator to return an ISO date string for the current
* julian date.
* @return ISO date string.
*/
String operator()() const;
/**
* Increment date by one day.
* @return instance of current date object.
*/
Date& operator++();
/**
* Decrement date by one day.
* @return instance of current date object.
*/
Date& operator--();
/**
* Increment date by offset.
* @param offset to add to julian date.
* @return instance of current date object.
*/
Date& operator+=(long offset);
/**
* Decrement date by offset.
* @param offset to subtract from julian date.
* @return instance of current date object.
*/
Date& operator-=(long offset);
/**
* Add days to julian date in an expression.
* @param days to add.
* @return new date object with modified days.
*/
Date operator+(long days);
/**
* Subtract days from a julian date in an expression.
* @param days to subtract.
* @return new date object with modified days.
*/
Date operator-(long days);
/**
* Operator to compute number of days between two dates.
* @param date offset for computation.
* @return number of days difference.
*/
inline long operator-(const Date &date)
{return (julian - date.julian);};
/**
* Assign date from another date object.
* @param date object to assign from.
* @return current modified date object.
*/
Date& operator=(const Date& date);
/**
* Compare julian dates if same date.
* @param date to compare with.
* @return true if same.
*/
bool operator==(const Date& date);
/**
* Compare julian dates if not same date.
* @param date to compare with.
* @return true if not same.
*/
bool operator!=(const Date& date);
/**
* Compare julian date if earlier than another date.
* @param date to compare with.
* @return true if earlier.
*/
bool operator<(const Date& date);
/**
* Compare julian date if earlier than or equal to another date.
* @param date to compare with.
* @return true if earlier or same.
*/
bool operator<=(const Date& date);
/**
* Compare julian date if later than another date.
* @param date to compare with.
* @return true if later.
*/
bool operator>(const Date& date);
/**
* Compare julian date if later than or equal to another date.
* @param date to compare with.
* @return true if later or same.
*/
bool operator>=(const Date& date);
/**
* Check if julian date is not valid.
* @return true if date is invalid.
*/
inline bool operator!() const
{return !isValid();};
/**
* Check if julian date is valid for is() expression.
* @return true if date is valid.
*/
inline operator bool() const
{return isValid();};
};
/**
* The Time class uses a integer representation of the current
* time. This is then manipulated in several forms and may be
* exported as needed. The time object can represent an instance in
* time (hours, minutes, and seconds) in a 24 hour period or can
* represent a duration. Millisecond accuracy can be offered.
*
* @author Marcelo Dalmas <mad@brasmap.com.br> and David Sugar <dyfet@gnutelephony.org>
* @short Integer based time class.
*/
class __EXPORT Time
{
protected:
long seconds;
protected:
void toSeconds(int hour, int minute = 0, int second = 0);
void fromSeconds(char *buf) const;
virtual void update(void);
public:
/**
* Component access index.
*/
typedef enum {hour = 20, minute, second} index_t;
/**
* Size of time string field.
*/
static const size_t sz_string;
/**
* Create a time from the time portion of a time_t.
* @param value of time_t to use.
*/
Time(time_t value);
/**
* Create a time from the time portion of a date and time object.
* @param object from DateTime::glt() or gmt().
*/
Time(struct tm *object);
/**
* Create a time from a hh:mm:ss formatted time string.
* @param pointer to formatted time field.
* @param size of field if not null terminated.
*/
Time(char *pointer, size_t size = 0);
/**
* Create a time from hours (0-23), minutes (0-59), and seconds (0-59).
* @param hour of time.
* @param minute of time.
* @param second of time.
*/
Time(int hour, int minute, int second);
/**
* Create a time object from another object.
* @param object to copy.
*/
Time(const Time& object);
/**
* Create a time from current time.
*/
Time();
/**
* Destroy time object.
*/
virtual ~Time();
/**
* Get current time in seconds from midnight.
* @return seconds from midnight.
*/
long get(void) const;
/**
* Get hours from midnight.
* @return hours from midnight.
*/
int getHour(void) const;
/**
* Get minutes from current hour.
* @return minutes from current hour.
*/
int getMinute(void) const;
/**
* Get seconds from current minute.
* @return seconds from current minute.
*/
int getSecond(void) const;
/**
* Get a hh:mm:ss formatted string for current time.
* @param buffer to store time string in.
* @return time string buffer or NULL if invalid.
*/
char *get(char *buffer) const;
/**
* Set (update) the time with current time.
*/
void set(void);
/**
* Set time from a hh:mm:ss formatted string.
* @param pointer to time field.
* @param size of field if not null terminated.
*/
void set(char *pointer, size_t size = 0);
/**
* Check if time object had valid value.
* @return true if object is valid.
*/
bool isValid(void) const;
/**
* Check if time object has valid value for is() operator.
* @return true if object is valid.
*/
inline operator bool() const
{return isValid();};
/**
* Check if time object has valid value for ! operator.
* @return true if object is not valid.
*/
inline bool operator!() const
{return !isValid();};
/**
* Get difference (in seconds) between two times.
* @param reference time to get difference from.
* @return difference in seconds.
*/
long operator-(const Time &reference);
/**
* Add seconds to the current time, wrap if 24 hours.
* @param seconds to add.
* @return new time object with modified value.
*/
Time operator+(long seconds);
/**
* Subtract seconds to the current time, wrap if 24 hours.
* @param seconds to subtract.
* @return new time object with modified value.
*/
Time operator-(long seconds);
/**
* Get time in seconds.
* @return seconds.
*/
inline operator long()
{return get();};
/**
* Get object time in seconds.
* @return time in seconds.
*/
inline long operator*() const
{return get();};
/**
* Get component of time object.
* @param component index.
* @return value of component.
*/
int operator[](index_t component) const;
/**
* Convert to standard 24 hour time string.
* @return time string.
*/
String operator()() const;
/**
* Incrememnt time by 1 second, wrap on 24 hour period.
* @return modified instance of current time object.
*/
Time& operator++();
/**
* Decrement time by 1 second, wrap on 24 hour period.
* @return modified instance of current time object.
*/
Time& operator--();
/**
* Assign a time as a copy of another time.
* @param time to assign from.
* @return time object that was assigned.
*/
Time& operator=(const Time& time);
/**
* Increment time by specified seconds. Wraps on 24 hour period.
* @param seconds to add to current time.
* @return modified instance of current time object.
*/
Time& operator+=(long seconds);
/**
* Decrement time by specified seconds. Wraps on 24 hour period.
* @param seconds to subtract from current time.
* @return modified instance of current time object.
*/
Time& operator-=(long seconds);
/**
* Compare time with another time to see if same time.
* @param time to compare with.
* @return true if same time.
*/
bool operator==(const Time &time);
/**
* Compare time with another time to see if not same time.
* @param time to compare with.
* @return true if not same time.
*/
bool operator!=(const Time &time);
/**
* Compare time if earlier than another time.
* @param time object to compare with.
* @return true if earlier than object.
*/
bool operator<(const Time &time);
/**
* Compare time if earlier than or equal to another time.
* @param time object to compare with.
* @return true if earlier or same as object.
*/
bool operator<=(const Time &time);
/**
* Compare time if later than another time.
* @param time object to compare with.
* @return true if later than object.
*/
bool operator>(const Time &time);
/**
* Compare time if later than or equal to another time.
* @param time object to compare with.
* @return true if later than or same as object.
*/
bool operator>=(const Time &time);
};
/**
* The Datetime class uses a julian date representation of the current
* year, month, and day and a integer representation of the current
* time. This is then manipulated in several forms
* and may be exported as needed.
*
* @author Marcelo Dalmas <mad@brasmap.com.br>
* @short Integer based time class.
*/
class __EXPORT DateTime : public Date, public Time
{
protected:
void update(void);
public:
/**
* Index to components we can access.
*/
typedef enum {year = Date::year, month = Date::month, day = Date::day,
dow = Date::dow,
hour = Time::hour, minute = Time::minute, second = Time::second} index_t;
/**
* Constant for number of seconds in a day.
*/
static const long c_day;
/**
* Constant for number of seconds in a hour.
*/
static const long c_hour;
/**
* Constant for number of seconds in a week.
*/
static const long c_week;
/**
* Size of datetime string field.
*/
static const size_t sz_string;
/**
* Construct a date and time from C libraray time_t type.
* @param time type to make date and time from.
*/
DateTime(time_t time);
/**
* Construct a date and time from C library time structure.
* @param tm structure from C library (from glt or gmt).
*/
DateTime(struct tm *tm);
/**
* Construct a date and time from ISO string buffer.
* @param pointer to string field holding date and time.
* @param size of field if not null terminated string.
*/
DateTime(const char *pointer, size_t size = 0);
/**
* Construct a date and time object from explicit date and time values.
* @param year of object.
* @param month of object (1-12).
* @param day of month of object (1-31).
* @param hour of object (0-23).
* @param minute of object (0-59).
* @param second of object (0-59).
*/
DateTime(int year, unsigned month, unsigned day,
int hour = 0, int minute = 0, int second = 0);
/**
* Create a datetime object from another object.
* @param object to copy.
*/
DateTime(const DateTime& object);
/**
* Construct a new date and time object with current date and time.
*/
DateTime();
/**
* Destroy date and time object.
*/
virtual ~DateTime();
/**
* Get a ISO formatted date and time string for current object.
* @param buffer to store date and time in (yyyy-mm-dd hh:mm:ss).
* @return string buffer if object is valid.
*/
char *get(char *buffer) const;
/**
* Get C library time_t type if object in C library epoch range.
* @return time in seconds from epoch or ~0l if out of range.
*/
time_t get(void) const;
/**
* Test if object is valid.
* @return true if object is valid.
*/
bool isValid(void) const;
/**
* Operator to compute number of days between two dates.
* @param datetime to offset from for computation.
* @return number of days difference.
*/
long operator-(const DateTime &datetime);
/**
* Assign date and time from another datetime object.
* @param datetime object to assign from.
* @return assigned datetime object.
*/
DateTime& operator=(const DateTime& datetime);
/**
* Add seconds to the current datetime object. Day overflows update
* julian date.
* @param seconds to add to object.
* @return modified datetime object.
*/
DateTime& operator+=(long seconds);
/**
* Subtract seconds from current datetime object. Day underflows
* update julian date.
* @param seconds to subtract from object.
* @return modified datetime object.
*/
DateTime& operator-=(long seconds);
/**
* Add seconds to datetime in an expression. Day overflows update
* julian date.
* @param seconds to add to datetime.
* @return new modified datetime object.
*/
DateTime operator+(long seconds);
/**
* Subtract seconds from datetime in an expression. Day underflows
* update julian date.
* @param seconds to subtract from datetime.
* @return new modified datetime object.
*/
DateTime operator-(long seconds);
/**
* Add a day from the current date and time.
* @return datetime object reference that was modified.
*/
DateTime& operator++();
/**
* Subtract a day from the current date and time.
* @return datetime object reference that was modified.
*/
DateTime& operator--();
/**
* Compare date and time with another date and time to see if the same.
* @param datetime to compare with.
* @return true if equal.
*/
bool operator==(const DateTime& datetime);
/**
* Compare date and time with another date and time to see if not same.
* @param datetime to compare with.
* @return true if not equal.
*/
bool operator!=(const DateTime& datetime);
/**
* Compare date and time with another date and time to see if earlier.
* @param datetime to compare with.
* @return true if earlier.
*/
bool operator<(const DateTime& datetime);
/**
* Compare date and time with another date and time to see if earlier or
* the same.
* @param datetime to compare with.
* @return true if earlier or equal.
*/
bool operator<=(const DateTime& datetime);
/**
* Compare date and time with another date and time to see if later.
* @param datetime to compare with.
* @return true if later.
*/
bool operator>(const DateTime& datetime);
/**
* Compare date and time with another date and time to see if later or
* the same.
* @param datetime to compare with.
* @return true if later or equal.
*/
bool operator>=(const DateTime& datetime);
/**
* Check if date and time is not valid.
* @return true if not valid.
*/
bool operator!() const;
/**
* Access time components.
* @param component to access.
* @return number or -1 if invalid.
*/
int operator[](index_t component) const;
/**
* Test is date and time is valid for is() operator.
* @return true if object is valid.
*/
operator bool() const;
/**
* Casting operator to return date as number.
* @return date as a number.
*/
inline operator long() const
{return Date::get();};
/**
* Set (update) the date and time with current date and time.
*/
void set(void);
/**
* Convert date and time to julian day number.
* @return julian day number as a double.
*/
operator double() const;
/**
* Return date and time formatted using strftime format values.
* @param strftime format to use.
* @return String object with formatted time.
*/
String format(const char *strftime) const;
/**
* Fetch an instance of time converted to local time. If the localtime
* abi is not re-entrant, than a lock is held, otherwise a unique
* object is returned. In either case, when you are done, you must
* release the object.
* @param time object or NULL if using current time.
* @return locked instance of struct tm object.
*/
static struct tm *glt(time_t *time = NULL);
/**
* Fetch an instance of time converted to gmt. If the gmtime abi
* is not re-entrant, than a lock is held, otherwise a unique
* object is returned. In either case, when you are done, you must
* release the object.
* @param time object or NULL if using current time.
* @return locked instance of struct tm object.
*/
static struct tm *gmt(time_t *time = NULL);
/**
* Release a struct tm object from glt or gmt.
* @param object to release.
*/
static void release(struct tm *object);
};
/**
* A DateTime string class. This can be used to access the date and time
* as a standard string without requiring an external buffer.
*
* @author David Sugar <dyfet@gnutelephony.org>
* @short a datetime class that returns strings.
*/
class __EXPORT DateTimeString : public DateTime
{
public:
/**
* Specify string buffer mode. By default we form a string with date
* and time.
*/
typedef enum {
DATE, TIME, BOTH} mode_t;
private:
char buffer[DATETIME_BUFFER_SIZE];
mode_t mode;
protected:
void update(void);
public:
/**
* Construct a date and time from C libraray time_t type.
* @param time type to make date and time from.
*/
DateTimeString(time_t time);
/**
* Construct a date and time from C library time structure.
* @param tm structure from C library (from glt or gmt).
*/
DateTimeString(struct tm *tm);
/**
* Construct a date and time from ISO string buffer.
* @param pointer to string field holding date and time.
* @param size of field if not null terminated string.
*/
DateTimeString(const char *pointer, size_t size = 0);
/**
* Construct a date and time object from explicit date and time values.
* @param year of object.
* @param month of object (1-12).
* @param day of month of object (1-31).
* @param hour of object (0-23).
* @param minute of object (0-59).
* @param second of object (0-59).
*/
DateTimeString(int year, unsigned month, unsigned day,
int hour = 0, int minute = 0, int second = 0);
/**
* Create a datetime object from another object.
* @param object to copy.
*/
DateTimeString(const DateTimeString& object);
/**
* Construct a new date and time object with current date and time.
*/
DateTimeString(mode_t string = DateTimeString::BOTH);
/**
* Destroy date time string.
*/
virtual ~DateTimeString();
/**
* Extract char from string.
*
* @return string of datetime.
*/
inline const char *c_str(void)
{return buffer;};
/**
* Cast to string.
*
* @return string of datetime.
*/
inline operator const char *(void)
{return buffer;};
/**
* Set (update) the date and time with current date and time.
*/
void set(void);
/**
* Set the string mode.
* @param string mode to use.
*/
void set(mode_t string);
};
/**
* A number class that manipulates a string buffer that is also a date.
*
* @author David Sugar <dyfet@ostel.com>
* @short a number that is also a date string.
*/
class __EXPORT DateNumber : public Number, public Date
{
protected:
void update(void);
public:
/**
* Create a date number tied to a refreshed string buffer.
* @param pointer to string buffer to rewrite.
*/
DateNumber(char *pointer);
/**
* Release a datenumber object.
*/
virtual ~DateNumber();
/**
* Set date number to current date.
*/
void set(void);
};
/**
* Convenience type for using DateTime object.
*/
typedef DateTime datetime_t;
/**
* Convenience type for using DateTimeString object.
*/
typedef DateTimeString datetimestring_t;
/**
* Convenience type for using Date object.
*/
typedef Date date_t;
/**
* Convenience type for struct tm.
*/
typedef struct tm tm_t;
END_NAMESPACE
#endif
|