zipios  2.2.0
Zipios – a small C++ library that provides easy access to .zip files.
dosdatetime.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef ZIPIOS_DOSDATETIME_HPP
3 #define ZIPIOS_DOSDATETIME_HPP
4 
5 /*
6  Zipios -- a small C++ library that provides easy access to .zip files.
7 
8  Copyright (C) 2019 Made to Order Software Corporation
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 2.1 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24 
32 #include <cstdint>
33 #include <ctime>
34 
35 #include <time.h>
36 
37 
38 namespace zipios
39 {
40 
41 
42 
43 
45 {
46 public:
47  typedef uint32_t dosdatetime_t;
48 
49  static dosdatetime_t const g_min_dosdatetime = 0x00210000; // Jan 1, 1980 00:00:00
50  static dosdatetime_t const g_max_dosdatetime = 0xFF9FBF7D; // Dec 31, 2107 23:59:59
51 
52  bool isValid() const;
53  int daysInMonth() const;
54  int getSecond() const;
55  int getMinute() const;
56  int getHour() const;
57  int getMDay() const;
58  int getMonth() const;
59  int getYear() const;
60  void setSecond(int second);
61  void setMinute(int minute);
62  void setHour(int hour);
63  void setMDay(int mday);
64  void setMonth(int month);
65  void setYear(int year);
66  dosdatetime_t getDOSDateTime() const;
67  void setDOSDateTime(dosdatetime_t datetime);
68  void setUnixTimestamp(std::time_t unix_timestamp);
69  std::time_t getUnixTimestamp() const;
70 
71 protected:
72  dosdatetime_t m_dosdatetime = 0;
73 };
74 
75 
76 
77 
78 } // zipios namespace
79 
80 // Local Variables:
81 // mode: cpp
82 // indent-tabs-mode: nil
83 // c-basic-offset: 4
84 // tab-width: 4
85 // End:
86 
87 // vim: ts=4 sw=4 et
88 #endif
dosdatetime_t m_dosdatetime
Definition: dosdatetime.hpp:72
std::time_t getUnixTimestamp() const
Retrieve the DOSDateTime as a Unix timestamp.
The zipios namespace includes the Zipios library definitions.
Definition: backbuffer.cpp:35
int getHour() const
Get the hour.
void setMDay(int mday)
Set the day of the month.
dosdatetime_t getDOSDateTime() const
Retrieve the DOSDateTime value as is.
void setUnixTimestamp(std::time_t unix_timestamp)
Set the DOSDateTime value from a Unix timestamp.
int getMonth() const
Get the month.
static dosdatetime_t const g_max_dosdatetime
Definition: dosdatetime.hpp:50
bool isValid() const
Check whether this DOS Date & Date is valid.
int daysInMonth() const
Calculate the number of days in this date&#39;s month.
void setMinute(int minute)
Set the minute.
int getMDay() const
Get the day of the month.
void setSecond(int second)
Set the second.
int getSecond() const
Get the second.
int getMinute() const
Get the minute.
void setYear(int year)
Set the year.
void setHour(int hour)
Set the hour.
int getYear() const
Get the year.
void setDOSDateTime(dosdatetime_t datetime)
Set the DOSDateTime value as is.
void setMonth(int month)
Set the month.
static dosdatetime_t const g_min_dosdatetime
Definition: dosdatetime.hpp:49