X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fstlplus%2Fportability%2Ftime.hpp;h=d9907e63590b5c7d8cbec32ecb5861cc8445b37f;hp=f8abe6cfedd6c7e65f824423af943c9247c18370;hb=5846afb00833cc72fe72422ca896d2387c712cb4;hpb=a97500609dc3c1b11f9786d32bc458eb00de4c36 diff --git a/src/stlplus/portability/time.hpp b/src/stlplus/portability/time.hpp index f8abe6c..d9907e6 100644 --- a/src/stlplus/portability/time.hpp +++ b/src/stlplus/portability/time.hpp @@ -1,55 +1,55 @@ -#ifndef STLPLUS_TIME -#define STLPLUS_TIME -//////////////////////////////////////////////////////////////////////////////// - -// Author: Andy Rushton -// Copyright: (c) Southampton University 1999-2004 -// (c) Andy Rushton 2004-2009 -// License: BSD License, see ../docs/license.html - -// Simplified access to representations of time and conversions between them. -// The motivation for this package is that the low-level system calls for -// accessing time are ugly and therefore potentially error-prone. I hope that -// this interface is much simpler and therefore easier to use and more likely -// to yield first-time right programs. - -// time is represented as the built-in integer type time_t - this is the -// standard representation of system time in computerland and represents the -// number of seconds since midnight 1 Jan 1970, believe it or not. - -// Functions are provided here for converting to and from more -// human-comprehendable forms. - -//////////////////////////////////////////////////////////////////////////////// -#include "portability_fixes.hpp" -#include -#include - -namespace stlplus -{ - - // get the integer representing the time now - time_t time_now(void); - - // get the integer representing the requested time - the local time is expressed in the local timezone - time_t localtime_create(int year, int month, int day, int hour, int minute, int second); - - // extract human-centric form of the machine representation time_t - int localtime_year(time_t); // the year e.g. 1962 - int localtime_month(time_t); // the month, numbered 1-12 e.g. August = 8 - int localtime_day(time_t); // the day of the month numbered 1-31 e.g. 29 - int localtime_hour(time_t); // the hour of day numbered 0-23 - int localtime_minute(time_t); // minute past the hour numbered 0-59 - int localtime_second(time_t); // second past the minute numbered 0-59 - int localtime_weekday(time_t); // the day of the week numbered 0-6 with 0=Sunday - int localtime_yearday(time_t); // the number of days into the year - - // convert the integer representation of time to a human-readable form - std::string localtime_string(time_t); - - // convert a time delay in seconds to human-readable form - std::string delaytime_string(time_t); - -} // end namespace stlplus - -#endif +#ifndef STLPLUS_TIME +#define STLPLUS_TIME +//////////////////////////////////////////////////////////////////////////////// + +// Author: Andy Rushton +// Copyright: (c) Southampton University 1999-2004 +// (c) Andy Rushton 2004-2009 +// License: BSD License, see ../docs/license.html + +// Simplified access to representations of time and conversions between them. +// The motivation for this package is that the low-level system calls for +// accessing time are ugly and therefore potentially error-prone. I hope that +// this interface is much simpler and therefore easier to use and more likely +// to yield first-time right programs. + +// time is represented as the built-in integer type time_t - this is the +// standard representation of system time in computerland and represents the +// number of seconds since midnight 1 Jan 1970, believe it or not. + +// Functions are provided here for converting to and from more +// human-comprehendable forms. + +//////////////////////////////////////////////////////////////////////////////// +#include "portability_fixes.hpp" +#include +#include + +namespace stlplus +{ + + // get the integer representing the time now + time_t time_now(void); + + // get the integer representing the requested time - the local time is expressed in the local timezone + time_t localtime_create(int year, int month, int day, int hour, int minute, int second); + + // extract human-centric form of the machine representation time_t + int localtime_year(time_t); // the year e.g. 1962 + int localtime_month(time_t); // the month, numbered 1-12 e.g. August = 8 + int localtime_day(time_t); // the day of the month numbered 1-31 e.g. 29 + int localtime_hour(time_t); // the hour of day numbered 0-23 + int localtime_minute(time_t); // minute past the hour numbered 0-59 + int localtime_second(time_t); // second past the minute numbered 0-59 + int localtime_weekday(time_t); // the day of the week numbered 0-6 with 0=Sunday + int localtime_yearday(time_t); // the number of days into the year + + // convert the integer representation of time to a human-readable form + std::string localtime_string(time_t); + + // convert a time delay in seconds to human-readable form + std::string delaytime_string(time_t); + +} // end namespace stlplus + +#endif