Tweaks to LocalTime; build/install fixes.
[libdcp.git] / src / local_time.h
1 /*
2     Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef LIBDCP_LOCAL_TIME_H
21 #define LIBDCP_LOCAL_TIME_H
22
23 #include <boost/date_time/posix_time/posix_time.hpp>
24 #include <string>
25
26 class local_time_test;
27
28 namespace dcp {
29
30 /** I tried to use boost for this, really I did, but I could not get it
31  *  to parse strings of the required format (those that include time zones).
32  */
33 class LocalTime
34 {
35 public:
36         LocalTime ();
37         LocalTime (boost::posix_time::ptime);
38         LocalTime (std::string);
39
40         std::string as_string () const;
41         std::string date () const;
42         std::string time_of_day () const;
43
44 private:
45         friend class ::local_time_test;
46
47         void set_local_time_zone ();
48
49         /* Local time */
50         int _year;
51         int _month;
52         int _day;
53         int _hour;
54         int _minute;
55         int _second;
56
57         /* Amount by which this time is offset from UTC */
58         int _tz_hour;
59         int _tz_minute;
60 };
61
62 }
63
64 #endif