1 /**************************************************************************
2 ** (c) Copyright 1999, Andromeda Technology & Automation
3 ***************************************************************************
4 ** MODULE INFORMATION *
5 ***********************
7 ** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation
8 ** VERSION NUMBER : $Revision: 1.1 $
15 ***************************************************************************
16 ** ADMINISTRATIVE INFORMATION *
17 ********************************
18 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
19 ** CREATION DATE : Sep 16, 2002
20 ** LAST UPDATE : Sep 16, 2002
21 **************************************************************************/
23 /*****************************
25 Revision 1.1 2002-09-28 06:58:45 arjen
26 Bugfix: conversion of an empty string to a date or hour object
27 now makes the values of such an object 0 (null) instead of giving
29 The class UTC combines the date and hour classes. The most basic
30 functions of the UTC class are now implemented.
31 These include constructors and conversion to and from String objects.
32 New functions: date::proper(), hour::proper() and UTC::proper().
33 Return true if the object holds a proper clock time and/or calendar
34 date; false if at least one value is out of range.
37 *****************************/
39 static const char *RCSID = "$Id: utc.cpp,v 1.1 2002-09-28 06:58:45 arjen Exp $";
44 #include "parsedate.h"
48 struct parseddate *pd;
63 t.minutes = pd->minute;
64 t.seconds = pd->second;
79 tp = localtime(&clock);
81 t = hour(tp->tm_hour, tp->tm_min, tp->tm_sec);
82 d = date(tp->tm_mday, tp->tm_mon+1, tp->tm_year+1900);
87 UTC operator+(UTC &t1, UTC &t2)
97 UTC UTC::operator+=(UTC u)
105 std::ostream& operator<<(std::ostream &s, const UTC &t)
107 s << t.d << " " << t.t;
112 std::istream &operator>>(std::istream &s, UTC &t)
119 String UTC::format(const char *fmt)
125 ut.tm_sec = t.seconds;
126 ut.tm_min = t.minutes;
127 ut.tm_hour = t.hours;
128 ut.tm_year = d.year - 1900;
129 ut.tm_mon = d.month - 1;
132 strftime(buf, 80, fmt, &ut);