]> Dogcows Code - chaz/yoink/blob - src/stlplus/portability/time.hpp
import stlplus 3.7
[chaz/yoink] / src / stlplus / portability / time.hpp
1 #ifndef STLPLUS_TIME
2 #define STLPLUS_TIME
3 ////////////////////////////////////////////////////////////////////////////////
4
5 // Author: Andy Rushton
6 // Copyright: (c) Southampton University 1999-2004
7 // (c) Andy Rushton 2004 onwards
8 // License: BSD License, see ../docs/license.html
9
10 // Simplified access to representations of time and conversions between them.
11 // The motivation for this package is that the low-level system calls for
12 // accessing time are ugly and therefore potentially error-prone. I hope that
13 // this interface is much simpler and therefore easier to use and more likely
14 // to yield first-time right programs.
15
16 // time is represented as the built-in integer type time_t - this is the
17 // standard representation of system time in computerland and represents the
18 // number of seconds since midnight 1 Jan 1970, believe it or not.
19
20 // Functions are provided here for converting to and from more
21 // human-comprehendable forms.
22
23 ////////////////////////////////////////////////////////////////////////////////
24 #include "portability_fixes.hpp"
25 #include <string>
26 #include <time.h>
27
28 namespace stlplus
29 {
30
31 // get the integer representing the time now
32 time_t time_now(void);
33
34 // get the integer representing the requested time - the local time is expressed in the local timezone
35 time_t localtime_create(int year, int month, int day, int hour, int minute, int second);
36
37 // extract human-centric form of the machine representation time_t
38 int localtime_year(time_t); // the year e.g. 1962
39 int localtime_month(time_t); // the month, numbered 1-12 e.g. August = 8
40 int localtime_day(time_t); // the day of the month numbered 1-31 e.g. 29
41 int localtime_hour(time_t); // the hour of day numbered 0-23
42 int localtime_minute(time_t); // minute past the hour numbered 0-59
43 int localtime_second(time_t); // second past the minute numbered 0-59
44 int localtime_weekday(time_t); // the day of the week numbered 0-6 with 0=Sunday
45 int localtime_yearday(time_t); // the number of days into the year
46
47 // convert the integer representation of time to a human-readable form
48 std::string localtime_string(time_t);
49
50 // convert a time delay in seconds to human-readable form
51 std::string delaytime_string(time_t);
52
53 } // end namespace stlplus
54
55 #endif
This page took 0.029616 seconds and 4 git commands to generate.