LibreOffice: osl/time.h Source File

LibreOffice LibreOffice 7.1 SDK C/C++ API Reference

time.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_OSL_TIME_H
21#define INCLUDED_OSL_TIME_H
22
23#include "sal/config.h"
24
25#if defined LIBO_INTERNAL_ONLY && defined __cplusplus
26#include <chrono>
27#endif
28
29#include "sal/saldllapi.h"
30#include "sal/types.h"
31
32#ifdef _WIN32
33# pragma pack(push, 8)
34#endif
35
36/* Time since Jan-01-1970 */
37
38#if defined LIBO_INTERNAL_ONLY && defined __cplusplus
39
40struct TimeValue {
41 TimeValue() = default;
42
43 constexpr TimeValue(sal_uInt32 seconds, sal_uInt32 nanoseconds):
44 Seconds(seconds), Nanosec(nanoseconds) {}
45
46 template<typename Rep, typename Period> constexpr
47 TimeValue(std::chrono::duration<Rep, Period> const & duration):
48 Seconds(
49 std::chrono::duration_cast<std::chrono::nanoseconds>(
50 duration).count() / 1000000000),
51 Nanosec(
52 std::chrono::duration_cast<std::chrono::nanoseconds>(
53 duration).count() % 1000000000)
54 {}
55
56 sal_uInt32 Seconds;
57 sal_uInt32 Nanosec;
58};
59
60#else
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
66 typedef struct {
67 sal_uInt32 Seconds;
68 sal_uInt32 Nanosec;
69} TimeValue;
70
71#ifdef __cplusplus
72}
73#endif
74
75#endif
76
77#if defined(_WIN32)
78# pragma pack(pop)
79#endif
80
81#ifdef __cplusplus
82extern "C" {
83#endif
84
85 typedef struct _oslDateTime
86{
89 sal_uInt32 NanoSeconds;
90
93 sal_uInt16 Seconds;
94
97 sal_uInt16 Minutes;
98
101 sal_uInt16 Hours;
102
105 sal_uInt16 Day;
106
109 sal_uInt16 DayOfWeek;
110
113 sal_uInt16 Month;
114
117 sal_Int16 Year;
118
119} oslDateTime;
120
121
125 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getSystemTime(
126 TimeValue* pTimeVal );
127
128
135 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getDateTimeFromTimeValue(
136 const TimeValue* pTimeVal, oslDateTime* pDateTime );
137
138
145 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getTimeValueFromDateTime(
146 const oslDateTime* pDateTime, TimeValue* pTimeVal );
147
148
155 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime(
156 const TimeValue* pSystemTimeVal, TimeValue* pLocalTimeVal );
157
158
165 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime(
166 const TimeValue* pLocalTimeVal, TimeValue* pSystemTimeVal );
167
168
173 SAL_DLLPUBLIC sal_uInt32 SAL_CALL osl_getGlobalTimer(void);
174
175#ifdef __cplusplus
176}
177#endif
178
179#endif // INCLUDED_OSL_TIME_H
180
181/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
saldllapi.h
SAL_DLLPUBLIC
#define SAL_DLLPUBLIC
Definition: saldllapi.h:30
types.h
sal_Bool
unsigned char sal_Bool
Definition: types.h:34
config.h
osl_getTimeValueFromDateTime
SAL_DLLPUBLIC sal_Bool osl_getTimeValueFromDateTime(const oslDateTime *pDateTime, TimeValue *pTimeVal)
Get the GMT from a oslDateTime and fill a TimeValue.
osl_getDateTimeFromTimeValue
SAL_DLLPUBLIC sal_Bool osl_getDateTimeFromTimeValue(const TimeValue *pTimeVal, oslDateTime *pDateTime)
Get the GMT from a TimeValue and fill a struct oslDateTime.
osl_getGlobalTimer
SAL_DLLPUBLIC sal_uInt32 osl_getGlobalTimer(void)
Get the value of the global timer.
osl_getSystemTimeFromLocalTime
SAL_DLLPUBLIC sal_Bool osl_getSystemTimeFromLocalTime(const TimeValue *pLocalTimeVal, TimeValue *pSystemTimeVal)
Convert local time to GMT.
oslDateTime
struct _oslDateTime oslDateTime
osl_getLocalTimeFromSystemTime
SAL_DLLPUBLIC sal_Bool osl_getLocalTimeFromSystemTime(const TimeValue *pSystemTimeVal, TimeValue *pLocalTimeVal)
Convert GMT to local time.
osl_getSystemTime
SAL_DLLPUBLIC sal_Bool osl_getSystemTime(TimeValue *pTimeVal)
Get the current system time as TimeValue.
TimeValue
Definition: time.h:66
TimeValue::Seconds
sal_uInt32 Seconds
Definition: time.h:67
TimeValue::Nanosec
sal_uInt32 Nanosec
Definition: time.h:68
_oslDateTime
Definition: time.h:86
_oslDateTime::Year
sal_Int16 Year
is the year.
Definition: time.h:117
_oslDateTime::NanoSeconds
sal_uInt32 NanoSeconds
contains the nanoseconds
Definition: time.h:89
_oslDateTime::Hours
sal_uInt16 Hours
contains the hour (0-23).
Definition: time.h:101
_oslDateTime::Month
sal_uInt16 Month
is the month of year (1-12).
Definition: time.h:113
_oslDateTime::DayOfWeek
sal_uInt16 DayOfWeek
is the day of week (0-6 , 0 : Sunday).
Definition: time.h:109
_oslDateTime::Seconds
sal_uInt16 Seconds
contains the seconds (0-59).
Definition: time.h:93
_oslDateTime::Day
sal_uInt16 Day
is the day of month (1-31).
Definition: time.h:105
_oslDateTime::Minutes
sal_uInt16 Minutes
contains the minutes (0-59).
Definition: time.h:97