2 Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 libdcp is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with libdcp. If not, see <http://www.gnu.org/licenses/>.
20 /** @file src/local_time.h
21 * @brief LocalTime class.
24 #ifndef LIBDCP_LOCAL_TIME_H
25 #define LIBDCP_LOCAL_TIME_H
27 #include <boost/date_time/posix_time/posix_time.hpp>
30 class local_time_test;
35 * @brief A representation of a local time (down to the second), including its offset
36 * from GMT (equivalent to xs:dateTime).
38 * I tried to use boost for this, really I did, but I could not get it
39 * to parse strings of the required format (those that include time zones).
41 * See http://www.w3.org/TR/xmlschema-2/#dateTime
47 explicit LocalTime (boost::posix_time::ptime);
48 LocalTime (boost::posix_time::ptime, int tz_hour, int tz_minute);
49 explicit LocalTime (std::string);
51 std::string as_string (bool with_millisecond = false) const;
52 std::string date () const;
53 std::string time_of_day (bool with_millisecond = false) const;
55 bool operator== (LocalTime const & other) const;
56 bool operator!= (LocalTime const & other) const;
59 friend class ::local_time_test;
61 void set_local_time_zone ();
65 int _month; ///< month number of the year (1-12)
66 int _day; ///< day number of the month (1-31)
67 int _hour; ///< hour number of the day (0-23)
68 int _minute; ///< minute number of the hour (0-59)
69 int _second; ///< second number of the minute (0-59)
70 int _millisecond; ///< millisecond number of the second (0-999)
72 int _tz_hour; ///< hours by which this time is offset from UTC
73 int _tz_minute; ///< minutes by which this time is offset from UTC
77 operator<< (std::ostream& s, LocalTime const & t);