LibreOffice LibreOffice 7.2 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/*
21 * This file is part of LibreOffice published API.
22 */
23
24#ifndef INCLUDED_OSL_TIME_H
25#define INCLUDED_OSL_TIME_H
26
27#include "sal/config.h"
28
29#if defined LIBO_INTERNAL_ONLY
30#if defined __cplusplus
31#include <chrono>
32#endif
33#endif
34
35#include "sal/saldllapi.h"
36#include "sal/types.h"
37
38#ifdef _WIN32
39# pragma pack(push, 8)
40#endif
41
42/* Time since Jan-01-1970 */
43
44#if defined LIBO_INTERNAL_ONLY && defined __cplusplus
45
46 struct TimeValue {
47 TimeValue() = default;
48
49 constexpr TimeValue(sal_uInt32 seconds, sal_uInt32 nanoseconds):
50 Seconds(seconds), Nanosec(nanoseconds) {}
51
52 template<typename Rep, typename Period> constexpr
53 TimeValue(std::chrono::duration<Rep, Period> const & duration):
54 Seconds(
55 std::chrono::duration_cast<std::chrono::nanoseconds>(
56 duration).count() / 1000000000),
57 Nanosec(
58 std::chrono::duration_cast<std::chrono::nanoseconds>(
59 duration).count() % 1000000000)
60 {}
61
62 sal_uInt32 Seconds;
63 sal_uInt32 Nanosec;
64};
65
66#else
67
68#ifdef __cplusplus
69 extern "C" {
70#endif
71
72 typedef struct {
73 sal_uInt32 Seconds;
74 sal_uInt32 Nanosec;
75} TimeValue;
76
77#ifdef __cplusplus
78}
79#endif
80
81#endif
82
83#if defined(_WIN32)
84# pragma pack(pop)
85#endif
86
87#ifdef __cplusplus
88 extern "C" {
89#endif
90
91 typedef struct _oslDateTime
92{
95 sal_uInt32 NanoSeconds;
96
99 sal_uInt16 Seconds;
100
103 sal_uInt16 Minutes;
104
107 sal_uInt16 Hours;
108
111 sal_uInt16 Day;
112
115 sal_uInt16 DayOfWeek;
116
119 sal_uInt16 Month;
120
123 sal_Int16 Year;
124
125} oslDateTime;
126
127
131 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getSystemTime(
132 TimeValue* pTimeVal );
133
134
141 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getDateTimeFromTimeValue(
142 const TimeValue* pTimeVal, oslDateTime* pDateTime );
143
144
151 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getTimeValueFromDateTime(
152 const oslDateTime* pDateTime, TimeValue* pTimeVal );
153
154
161 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime(
162 const TimeValue* pSystemTimeVal, TimeValue* pLocalTimeVal );
163
164
171 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime(
172 const TimeValue* pLocalTimeVal, TimeValue* pSystemTimeVal );
173
174
179 SAL_DLLPUBLIC sal_uInt32 SAL_CALL osl_getGlobalTimer(void);
180
181#ifdef __cplusplus
182}
183#endif
184
185#endif // INCLUDED_OSL_TIME_H
186
187/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
saldllapi.h
SAL_DLLPUBLIC
#define SAL_DLLPUBLIC
Definition: saldllapi.h:34
types.h
sal_Bool
unsigned char sal_Bool
Definition: types.h:38
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:72
TimeValue::Seconds
sal_uInt32 Seconds
Definition: time.h:73
TimeValue::Nanosec
sal_uInt32 Nanosec
Definition: time.h:74
_oslDateTime
Definition: time.h:92
_oslDateTime::Year
sal_Int16 Year
is the year.
Definition: time.h:123
_oslDateTime::NanoSeconds
sal_uInt32 NanoSeconds
contains the nanoseconds
Definition: time.h:95
_oslDateTime::Hours
sal_uInt16 Hours
contains the hour (0-23).
Definition: time.h:107
_oslDateTime::Month
sal_uInt16 Month
is the month of year (1-12).
Definition: time.h:119
_oslDateTime::DayOfWeek
sal_uInt16 DayOfWeek
is the day of week (0-6 , 0 : Sunday).
Definition: time.h:115
_oslDateTime::Seconds
sal_uInt16 Seconds
contains the seconds (0-59).
Definition: time.h:99
_oslDateTime::Day
sal_uInt16 Day
is the day of month (1-31).
Definition: time.h:111
_oslDateTime::Minutes
sal_uInt16 Minutes
contains the minutes (0-59).
Definition: time.h:103