mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added a method Time::getCompilationDate()
This commit is contained in:
parent
0b20c60e95
commit
ab774b814e
3 changed files with 55 additions and 31 deletions
|
|
@ -97,6 +97,7 @@ static String getAllSystemInfo()
|
|||
<< newLine
|
||||
<< "Time and date: " << Time::getCurrentTime().toString (true, true) << newLine
|
||||
<< "System up-time: " << RelativeTime::milliseconds ((int64) Time::getMillisecondCounterHiRes()).getDescription() << newLine
|
||||
<< "Compilation date: " << Time::getCompilationDate().toString (true, false) << newLine
|
||||
<< newLine
|
||||
<< "Operating system: " << SystemStats::getOperatingSystemName() << newLine
|
||||
<< "Host name: " << SystemStats::getComputerName() << newLine
|
||||
|
|
|
|||
|
|
@ -407,11 +407,11 @@ String Time::getWeekdayName (const bool threeLetterVersion) const
|
|||
return getWeekdayName (getDayOfWeek(), threeLetterVersion);
|
||||
}
|
||||
|
||||
static const char* const shortMonthNames[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
||||
static const char* const longMonthNames[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
|
||||
|
||||
String Time::getMonthName (int monthNumber, const bool threeLetterVersion)
|
||||
{
|
||||
static const char* const shortMonthNames[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
||||
static const char* const longMonthNames[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
|
||||
|
||||
monthNumber %= 12;
|
||||
|
||||
return TRANS (threeLetterVersion ? shortMonthNames [monthNumber]
|
||||
|
|
@ -430,17 +430,40 @@ String Time::getWeekdayName (int day, const bool threeLetterVersion)
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
Time& Time::operator+= (RelativeTime delta) { millisSinceEpoch += delta.inMilliseconds(); return *this; }
|
||||
Time& Time::operator-= (RelativeTime delta) { millisSinceEpoch -= delta.inMilliseconds(); return *this; }
|
||||
Time& Time::operator+= (RelativeTime delta) noexcept { millisSinceEpoch += delta.inMilliseconds(); return *this; }
|
||||
Time& Time::operator-= (RelativeTime delta) noexcept { millisSinceEpoch -= delta.inMilliseconds(); return *this; }
|
||||
|
||||
Time operator+ (Time time, RelativeTime delta) { Time t (time); return t += delta; }
|
||||
Time operator- (Time time, RelativeTime delta) { Time t (time); return t -= delta; }
|
||||
Time operator+ (RelativeTime delta, Time time) { Time t (time); return t += delta; }
|
||||
const RelativeTime operator- (Time time1, Time time2) { return RelativeTime::milliseconds (time1.toMilliseconds() - time2.toMilliseconds()); }
|
||||
Time operator+ (Time time, RelativeTime delta) noexcept { Time t (time); return t += delta; }
|
||||
Time operator- (Time time, RelativeTime delta) noexcept { Time t (time); return t -= delta; }
|
||||
Time operator+ (RelativeTime delta, Time time) noexcept { Time t (time); return t += delta; }
|
||||
const RelativeTime operator- (Time time1, Time time2) noexcept { return RelativeTime::milliseconds (time1.toMilliseconds() - time2.toMilliseconds()); }
|
||||
|
||||
bool operator== (Time time1, Time time2) { return time1.toMilliseconds() == time2.toMilliseconds(); }
|
||||
bool operator!= (Time time1, Time time2) { return time1.toMilliseconds() != time2.toMilliseconds(); }
|
||||
bool operator< (Time time1, Time time2) { return time1.toMilliseconds() < time2.toMilliseconds(); }
|
||||
bool operator> (Time time1, Time time2) { return time1.toMilliseconds() > time2.toMilliseconds(); }
|
||||
bool operator<= (Time time1, Time time2) { return time1.toMilliseconds() <= time2.toMilliseconds(); }
|
||||
bool operator>= (Time time1, Time time2) { return time1.toMilliseconds() >= time2.toMilliseconds(); }
|
||||
bool operator== (Time time1, Time time2) noexcept { return time1.toMilliseconds() == time2.toMilliseconds(); }
|
||||
bool operator!= (Time time1, Time time2) noexcept { return time1.toMilliseconds() != time2.toMilliseconds(); }
|
||||
bool operator< (Time time1, Time time2) noexcept { return time1.toMilliseconds() < time2.toMilliseconds(); }
|
||||
bool operator> (Time time1, Time time2) noexcept { return time1.toMilliseconds() > time2.toMilliseconds(); }
|
||||
bool operator<= (Time time1, Time time2) noexcept { return time1.toMilliseconds() <= time2.toMilliseconds(); }
|
||||
bool operator>= (Time time1, Time time2) noexcept { return time1.toMilliseconds() >= time2.toMilliseconds(); }
|
||||
|
||||
static int getMonthNumberForCompileDate (const String& m) noexcept
|
||||
{
|
||||
for (int i = 0; i < 12; ++i)
|
||||
if (m.equalsIgnoreCase (shortMonthNames[i]))
|
||||
return i;
|
||||
|
||||
// If you hit this because your compiler has a non-standard __DATE__ format,
|
||||
// let me know so we can add support for it!
|
||||
jassertfalse;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Time Time::getCompilationDate()
|
||||
{
|
||||
StringArray dateTokens;
|
||||
dateTokens.addTokens (__DATE__, true);
|
||||
dateTokens.removeEmptyStrings (true);
|
||||
|
||||
return Time (dateTokens[2].getIntValue(),
|
||||
getMonthNumberForCompileDate (dateTokens[0]),
|
||||
dateTokens[1].getIntValue(), 12, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,9 +253,9 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** Adds a RelativeTime to this time. */
|
||||
Time& operator+= (RelativeTime delta);
|
||||
Time& operator+= (RelativeTime delta) noexcept;
|
||||
/** Subtracts a RelativeTime from this time. */
|
||||
Time& operator-= (RelativeTime delta);
|
||||
Time& operator-= (RelativeTime delta) noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** Tries to set the computer's clock.
|
||||
|
|
@ -272,8 +272,7 @@ public:
|
|||
@param threeLetterVersion if true, it'll return a 3-letter abbreviation, e.g. "Tue"; if
|
||||
false, it'll return the full version, e.g. "Tuesday".
|
||||
*/
|
||||
static String getWeekdayName (int dayNumber,
|
||||
bool threeLetterVersion);
|
||||
static String getWeekdayName (int dayNumber, bool threeLetterVersion);
|
||||
|
||||
/** Returns the name of one of the months.
|
||||
|
||||
|
|
@ -281,8 +280,7 @@ public:
|
|||
@param threeLetterVersion if true, it'll be a 3-letter abbreviation, e.g. "Jan"; if false
|
||||
it'll return the long form, e.g. "January"
|
||||
*/
|
||||
static String getMonthName (int monthNumber,
|
||||
bool threeLetterVersion);
|
||||
static String getMonthName (int monthNumber, bool threeLetterVersion);
|
||||
|
||||
//==============================================================================
|
||||
// Static methods for getting system timers directly..
|
||||
|
|
@ -370,6 +368,8 @@ public:
|
|||
*/
|
||||
static int64 secondsToHighResolutionTicks (double seconds) noexcept;
|
||||
|
||||
/** Returns a Time based on the value of the __DATE__ macro when this module was compiled */
|
||||
static Time getCompilationDate();
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
|
@ -378,27 +378,27 @@ private:
|
|||
|
||||
//==============================================================================
|
||||
/** Adds a RelativeTime to a Time. */
|
||||
JUCE_API Time operator+ (Time time, RelativeTime delta);
|
||||
JUCE_API Time operator+ (Time time, RelativeTime delta) noexcept;
|
||||
/** Adds a RelativeTime to a Time. */
|
||||
JUCE_API Time operator+ (RelativeTime delta, Time time);
|
||||
JUCE_API Time operator+ (RelativeTime delta, Time time) noexcept;
|
||||
|
||||
/** Subtracts a RelativeTime from a Time. */
|
||||
JUCE_API Time operator- (Time time, RelativeTime delta);
|
||||
JUCE_API Time operator- (Time time, RelativeTime delta) noexcept;
|
||||
/** Returns the relative time difference between two times. */
|
||||
JUCE_API const RelativeTime operator- (Time time1, Time time2);
|
||||
JUCE_API const RelativeTime operator- (Time time1, Time time2) noexcept;
|
||||
|
||||
/** Compares two Time objects. */
|
||||
JUCE_API bool operator== (Time time1, Time time2);
|
||||
JUCE_API bool operator== (Time time1, Time time2) noexcept;
|
||||
/** Compares two Time objects. */
|
||||
JUCE_API bool operator!= (Time time1, Time time2);
|
||||
JUCE_API bool operator!= (Time time1, Time time2) noexcept;
|
||||
/** Compares two Time objects. */
|
||||
JUCE_API bool operator< (Time time1, Time time2);
|
||||
JUCE_API bool operator< (Time time1, Time time2) noexcept;
|
||||
/** Compares two Time objects. */
|
||||
JUCE_API bool operator<= (Time time1, Time time2);
|
||||
JUCE_API bool operator<= (Time time1, Time time2) noexcept;
|
||||
/** Compares two Time objects. */
|
||||
JUCE_API bool operator> (Time time1, Time time2);
|
||||
JUCE_API bool operator> (Time time1, Time time2) noexcept;
|
||||
/** Compares two Time objects. */
|
||||
JUCE_API bool operator>= (Time time1, Time time2);
|
||||
JUCE_API bool operator>= (Time time1, Time time2) noexcept;
|
||||
|
||||
|
||||
#endif // JUCE_TIME_H_INCLUDED
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue