OpenShot Audio Library | OpenShotAudio 0.3.2
Loading...
Searching...
No Matches
juce_Time.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2017 - ROLI Ltd.
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
36class JUCE_API Time
37{
38public:
39 //==============================================================================
46 Time() = default;
47
55 explicit Time (int64 millisecondsSinceEpoch) noexcept;
56
69 Time (int year,
70 int month,
71 int day,
72 int hours,
73 int minutes,
74 int seconds = 0,
75 int milliseconds = 0,
76 bool useLocalTime = true) noexcept;
77
79 ~Time() = default;
80
82
83 //==============================================================================
91 static Time JUCE_CALLTYPE getCurrentTime() noexcept;
92
98 int64 toMilliseconds() const noexcept { return millisSinceEpoch; }
99
103 int getYear() const noexcept;
104
109 int getMonth() const noexcept;
110
116 String getMonthName (bool threeLetterVersion) const;
117
121 int getDayOfMonth() const noexcept;
122
126 int getDayOfWeek() const noexcept;
127
131 int getDayOfYear() const noexcept;
132
137 String getWeekdayName (bool threeLetterVersion) const;
138
143 int getHours() const noexcept;
144
149 bool isAfternoon() const noexcept;
150
156 int getHoursInAmPmFormat() const noexcept;
157
159 int getMinutes() const noexcept;
160
162 int getSeconds() const noexcept;
163
171 int getMilliseconds() const noexcept;
172
174 bool isDaylightSavingTime() const noexcept;
175
176 //==============================================================================
178 String getTimeZone() const;
179
181 int getUTCOffsetSeconds() const noexcept;
182
187 String getUTCOffsetString (bool includeDividerCharacters) const;
188
189 //==============================================================================
202 String toString (bool includeDate,
203 bool includeTime,
204 bool includeSeconds = true,
205 bool use24HourClock = false) const;
206
238 String formatted (const String& format) const;
239
240 //==============================================================================
247 String toISO8601 (bool includeDividerCharacters) const;
248
250 static Time fromISO8601 (StringRef iso8601);
251
252 //==============================================================================
257
258 //==============================================================================
264 bool setSystemTimeToThisTime() const;
265
266 //==============================================================================
273 static String getWeekdayName (int dayNumber, bool threeLetterVersion);
274
281 static String getMonthName (int monthNumber, bool threeLetterVersion);
282
283 //==============================================================================
284 // Static methods for getting system timers directly..
285
293 static int64 currentTimeMillis() noexcept;
294
307 static uint32 getMillisecondCounter() noexcept;
308
316 static double getMillisecondCounterHiRes() noexcept;
317
322 static void waitForMillisecondCounter (uint32 targetTime) noexcept;
323
333 static uint32 getApproximateMillisecondCounter() noexcept;
334
335 //==============================================================================
336 // High-resolution timers..
337
346 static int64 getHighResolutionTicks() noexcept;
347
353 static int64 getHighResolutionTicksPerSecond() noexcept;
354
360 static double highResolutionTicksToSeconds (int64 ticks) noexcept;
361
367 static int64 secondsToHighResolutionTicks (double seconds) noexcept;
368
370 static Time getCompilationDate();
371
372private:
373 //==============================================================================
374 int64 millisSinceEpoch = 0;
375};
376
377//==============================================================================
379JUCE_API Time operator+ (Time time, RelativeTime delta) noexcept;
381JUCE_API Time operator+ (RelativeTime delta, Time time) noexcept;
382
384JUCE_API Time operator- (Time time, RelativeTime delta) noexcept;
387
389JUCE_API bool operator== (Time time1, Time time2) noexcept;
391JUCE_API bool operator!= (Time time1, Time time2) noexcept;
393JUCE_API bool operator< (Time time1, Time time2) noexcept;
395JUCE_API bool operator<= (Time time1, Time time2) noexcept;
397JUCE_API bool operator> (Time time1, Time time2) noexcept;
399JUCE_API bool operator>= (Time time1, Time time2) noexcept;
400
401} // namespace juce
Time()=default