API Documentation
Loading...
Searching...
No Matches
TimeZoneManager.h
Go to the documentation of this file.
1/**--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: TimeZoneManager
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/Time.h>
34#include <NDEVR/String.h>
35#include <NDEVR/UUID.h>
36#include <QTimeZone>
37namespace NDEVR
38{
46 {
47
48 static TimeZone convert(const QTimeZone& zone)
49 {
50 TimeZone time_zone;
51 time_zone.name = String(zone.id().toStdString());
52 time_zone.comment = String(zone.comment());
53 time_zone.id = UUID::CreateUUID(time_zone.name);
54 return time_zone;
55 }
56 static QTimeZone convert(const TimeZone& zone)
57 {
58 QTimeZone time_zone = QTimeZone(zone.name.getAs<QString>().toLocal8Bit());
59 return time_zone;
60 }
61 static QDateTime convert(const Time& time, const QTimeZone& zone)
62 {
63 QDateTime date_time;
64 date_time.setTimeZone(zone);
65 date_time.setTime_t(time.getMilliseconds());
66 return date_time;
67 }
68
69 static Buffer<TimeZone> Zones()
70 {
71 auto ids = QTimeZone::availableTimeZoneIds();
72 Buffer<TimeZone> zones;
73 for (auto id : ids)
74 {
75 zones.add(convert(QTimeZone(id)));
76 }
77 return zones;
78 }
79 static TimeZone SystemTimeZone()
80 {
81 return convert(QTimeZone::systemTimeZone());
82 }
83 static TimeZoneManager& defaultManager()
84 {
85 static TimeZoneManager s_time_zone_manager;
86 return s_time_zone_manager;
87 }
88 protected:
91 };
92}
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
void add(t_type &&object)
Definition Buffer.hpp:199
Definition String.h:40
t_type getAs() const
Definition String.h:334
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
uint08 getMilliseconds() const
Gets the timestamp in milliseconds.
Definition Time.h:193
Definition TimeZoneManager.h:46
QTimeZone m_q_current_timezone
Definition TimeZoneManager.h:90
TimeZone m_current_timezone
Definition TimeZoneManager.h:89
Definition UUID.h:66
static NDEVR_BASE_API UUID CreateUUID()
Definition UUID.cpp:150
Definition ACIColor.h:37
Definition TimeZoneManager.h:40
UUID id
Definition TimeZoneManager.h:43
String comment
Definition TimeZoneManager.h:42
String name
Definition TimeZoneManager.h:41