Loading...
Searching...
No Matches
juce_Time.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
class JUCE_API Time
{
public:
//==============================================================================
Time() = default;
explicit Time (int64 millisecondsSinceEpoch) noexcept;
Time (int year,
int month,
int day,
int hours,
int minutes,
int seconds = 0,
int milliseconds = 0,
bool useLocalTime = true) noexcept;
Time (const Time&) = default;
~Time() = default;
Time& operator= (const Time&) = default;
//==============================================================================
static Time JUCE_CALLTYPE getCurrentTime() noexcept;
int64 toMilliseconds() const noexcept { return millisSinceEpoch; }
int getYear() const noexcept;
int getMonth() const noexcept;
String getMonthName (bool threeLetterVersion) const;
int getDayOfMonth() const noexcept;
int getDayOfWeek() const noexcept;
int getDayOfYear() const noexcept;
String getWeekdayName (bool threeLetterVersion) const;
int getHours() const noexcept;
bool isAfternoon() const noexcept;
int getHoursInAmPmFormat() const noexcept;
int getMinutes() const noexcept;
int getSeconds() const noexcept;
int getMilliseconds() const noexcept;
bool isDaylightSavingTime() const noexcept;
//==============================================================================
String getTimeZone() const;
int getUTCOffsetSeconds() const noexcept;
String getUTCOffsetString (bool includeDividerCharacters) const;
//==============================================================================
String toString (bool includeDate,
bool includeTime,
bool includeSeconds = true,
bool use24HourClock = false) const;
String formatted (const String& format) const;
//==============================================================================
String toISO8601 (bool includeDividerCharacters) const;
static Time fromISO8601 (StringRef iso8601);
//==============================================================================
Time& operator+= (RelativeTime delta) noexcept;
Time& operator-= (RelativeTime delta) noexcept;
//==============================================================================
bool setSystemTimeToThisTime() const;
//==============================================================================
static String getWeekdayName (int dayNumber, bool threeLetterVersion);
static String getMonthName (int monthNumber, bool threeLetterVersion);
//==============================================================================
// Static methods for getting system timers directly..
static int64 currentTimeMillis() noexcept;
static uint32 getMillisecondCounter() noexcept;
static double getMillisecondCounterHiRes() noexcept;
static void waitForMillisecondCounter (uint32 targetTime) noexcept;
static uint32 getApproximateMillisecondCounter() noexcept;
//==============================================================================
// High-resolution timers..
static int64 getHighResolutionTicks() noexcept;
static int64 getHighResolutionTicksPerSecond() noexcept;
static double highResolutionTicksToSeconds (int64 ticks) noexcept;
static int64 secondsToHighResolutionTicks (double seconds) noexcept;
static Time getCompilationDate();
private:
//==============================================================================
int64 millisSinceEpoch = 0;
};
//==============================================================================
JUCE_API Time operator+ (Time time, RelativeTime delta) noexcept;
JUCE_API Time operator+ (RelativeTime delta, Time time) noexcept;
JUCE_API Time operator- (Time time, RelativeTime delta) noexcept;
JUCE_API RelativeTime operator- (Time time1, Time time2) noexcept;
JUCE_API bool operator== (Time time1, Time time2) noexcept;
JUCE_API bool operator!= (Time time1, Time time2) noexcept;
JUCE_API bool operator< (Time time1, Time time2) noexcept;
JUCE_API bool operator<= (Time time1, Time time2) noexcept;
JUCE_API bool operator> (Time time1, Time time2) noexcept;
JUCE_API bool operator>= (Time time1, Time time2) noexcept;
} // namespace juce
juce::RelativeTime
Definition juce_RelativeTime.h:37
juce::StringRef
Definition juce_StringRef.h:62
juce::String
Definition juce_String.h:53
juce::Time
Definition juce_Time.h:37
juce::Time::getApproximateMillisecondCounter
static uint32 getApproximateMillisecondCounter() noexcept
Definition juce_Time.cpp:261
juce::Time::Time
Time()=default
juce::Time::getHighResolutionTicks
static int64 getHighResolutionTicks() noexcept
juce::Time::getMillisecondCounterHiRes
static double getMillisecondCounterHiRes() noexcept
juce::Time::getWeekdayName
String getWeekdayName(bool threeLetterVersion) const
Definition juce_Time.cpp:537
juce::Time::currentTimeMillis
static int64 currentTimeMillis() noexcept
Definition juce_Time.cpp:220
juce::Time::getHighResolutionTicksPerSecond
static int64 getHighResolutionTicksPerSecond() noexcept
juce::Time::getCurrentTime
static Time JUCE_CALLTYPE getCurrentTime() noexcept
Definition juce_Time.cpp:233
juce::Time::getCompilationDate
static Time getCompilationDate()
Definition juce_Time.cpp:593
juce::Time::highResolutionTicksToSeconds
static double highResolutionTicksToSeconds(int64 ticks) noexcept
Definition juce_Time.cpp:293
juce::Time::secondsToHighResolutionTicks
static int64 secondsToHighResolutionTicks(double seconds) noexcept
Definition juce_Time.cpp:298
juce::Time::setSystemTimeToThisTime
bool setSystemTimeToThisTime() const
juce::Time::getMonthName
String getMonthName(bool threeLetterVersion) const
Definition juce_Time.cpp:532
juce::Time::waitForMillisecondCounter
static void waitForMillisecondCounter(uint32 targetTime) noexcept
Definition juce_Time.cpp:267
juce::Time::toMilliseconds
int64 toMilliseconds() const noexcept
Definition juce_Time.h:98
juce::Time::getMillisecondCounter
static uint32 getMillisecondCounter() noexcept
Definition juce_Time.cpp:241