TimeStamp.h
Go to the documentation of this file.
1 /****
2  * TimeStamp.h
3  *
4  * Copyright 2019 mikee47 <mike@sillyhouse.net>
5  *
6  * This file is part of the IFS Library
7  *
8  * This library is free software: you can redistribute it and/or modify it under the terms of the
9  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with this library.
16  * If not, see <https://www.gnu.org/licenses/>.
17  *
18  ****/
19 
20 #pragma once
21 
22 #include <cstdint>
23 #include <time.h>
24 #include <cstring>
25 #include <WString.h>
26 
27 namespace IFS
28 {
37 struct TimeStamp {
38  uint32_t mValue;
39 
40  operator time_t() const
41  {
42  return mValue;
43  }
44 
45  TimeStamp& operator=(time_t t)
46  {
47  mValue = t;
48  return *this;
49  }
50 
54  String toString(const char* dtsep = " ") const;
55 
56  explicit operator String() const
57  {
58  return toString();
59  }
60 };
61 
68 time_t fsGetTimeUTC();
69 
70 } // namespace IFS
71 
72 inline String toString(IFS::TimeStamp timestamp)
73 {
74  return timestamp.toString();
75 }
String toString(IFS::TimeStamp timestamp)
Definition: TimeStamp.h:72
The String class.
Definition: WString.h:137
Definition: DirectoryTemplate.h:37
time_t fsGetTimeUTC()
Get current timestamp in UTC.
Manage IFS timestamps stored as an unsigned 32-bit value.
Definition: TimeStamp.h:37
TimeStamp & operator=(time_t t)
Definition: TimeStamp.h:45
uint32_t mValue
Definition: TimeStamp.h:38
String toString(const char *dtsep=" ") const
Convert time to string for display.