// Copyright (c) 2014-2021 Thomas Fussell // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE // // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file #pragma once #include #include namespace xlnt { /// /// A time is a specific time of the day specified in terms of an hour, /// minute, second, and microsecond (0-999999). /// It can also be initialized as a fraction of a day using time::from_number. /// struct XLNT_API time { /// /// Return the current time according to the system time. /// static time now(); /// /// Return a time from a number representing a fraction of a day. /// The integer part of number will be ignored. /// 0.5 would return time(12, 0, 0, 0) or noon, halfway through the day. /// static time from_number(double number); /// /// Constructs a time object from an optional hour, minute, second, and microsecond. /// explicit time(int hour_ = 0, int minute_ = 0, int second_ = 0, int microsecond_ = 0); /// /// Constructs a time object from a string representing the time. /// explicit time(const std::string &time_string); /// /// Returns a numeric representation of the time in the range 0-1 where the value /// is equal to the fraction of the day elapsed. /// double to_number() const; /// /// Returns true if this time is equivalent to comparand. /// bool operator==(const time &comparand) const; /// /// The hour /// int hour; /// /// The minute /// int minute; /// /// The second /// int second; /// /// The microsecond /// int microsecond; }; } // namespace xlnt