+++ /dev/null
-/**************************************************************************
-** (c) Copyright 1999, Andromeda Technology & Automation
-***************************************************************************
-** MODULE INFORMATION *
-***********************
-** FILE NAME : utc.cpp
-** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation
-** VERSION NUMBER : $Revision: 1.1 $
-**
-** DESCRIPTION :
-**
-** EXPORTED OBJECTS :
-** LOCAL OBJECTS :
-** MODULES USED :
-***************************************************************************
-** ADMINISTRATIVE INFORMATION *
-********************************
-** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
-** CREATION DATE : Sep 16, 2002
-** LAST UPDATE : Sep 16, 2002
-**************************************************************************/
-
-/*****************************
- $Log: utc.cpp,v $
- Revision 1.1 2002-09-28 06:58:45 arjen
- Bugfix: conversion of an empty string to a date or hour object
- now makes the values of such an object 0 (null) instead of giving
- a segmentation fault.
- The class UTC combines the date and hour classes. The most basic
- functions of the UTC class are now implemented.
- These include constructors and conversion to and from String objects.
- New functions: date::proper(), hour::proper() and UTC::proper().
- Return true if the object holds a proper clock time and/or calendar
- date; false if at least one value is out of range.
-
-
-*****************************/
-
-static const char *RCSID = "$Id: utc.cpp,v 1.1 2002-09-28 06:58:45 arjen Exp $";
-
-#include <time.h>
-
-#include "date.h"
-#include "parsedate.h"
-
-UTC::UTC(String s)
-{
- struct parseddate *pd;
-
- if (~s == 0)
- {
- t.hours = 0;
- t.minutes = 0;
- t.seconds = 0;
- d.year = 0;
- d.month = 0;
- d.day = 0;
- }
- else
- {
- pd = parsedate(s);
- t.hours = pd->hour;
- t.minutes = pd->minute;
- t.seconds = pd->second;
- d.year = pd->year;
- d.month = pd->month;
- d.day = pd->day;
- }
-}
-
-UTC Now()
-{
- long clock;
- struct tm *tp;
- date d;
- hour t;
-
- time(&clock);
- tp = localtime(&clock);
-
- t = hour(tp->tm_hour, tp->tm_min, tp->tm_sec);
- d = date(tp->tm_mday, tp->tm_mon+1, tp->tm_year+1900);
-
- return UTC(d, t);
-}
-
-std::ostream& operator<<(std::ostream &s, const UTC &t)
-{
- s << t.d << " " << t.t;
-
- return s;
-}
-
-std::istream &operator>>(std::istream &s, UTC &t)
-{
- s >> t.d >> t.t;
-
- return s;
-}
-
-String UTC::format(const char *fmt)
-{
- String s;
- char buf[80];
- struct tm ut;
-
- ut.tm_sec = t.seconds;
- ut.tm_min = t.minutes;
- ut.tm_hour = t.hours;
- ut.tm_year = d.year - 1900;
- ut.tm_mon = d.month - 1;
- ut.tm_mday = d.day;
-
- strftime(buf, 80, fmt, &ut);
- s = buf;
-
- return s;
-}
-