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 {
36 struct TimeStamp {
37  uint32_t mValue;
38 
39  operator time_t() const
40  {
41  return mValue;
42  }
43 
44  TimeStamp& operator=(time_t t)
45  {
46  mValue = t;
47  return *this;
48  }
49 
53  String toString(const char* dtsep = " ") const;
54 
55  explicit operator String() const
56  {
57  return toString();
58  }
59 };
60 
67 time_t fsGetTimeUTC();
68 
69 } // namespace IFS
70 
71 inline String toString(IFS::TimeStamp timestamp)
72 {
73  return timestamp.toString();
74 }
String toString(IFS::TimeStamp timestamp)
Definition: TimeStamp.h:71
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:36
TimeStamp & operator=(time_t t)
Definition: TimeStamp.h:44
uint32_t mValue
Definition: TimeStamp.h:37
String toString(const char *dtsep=" ") const
Convert time to local time for display.