You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Add utc param to get_time and get_date methods
If utc == false, we return the local time, like before. Otherwise, we return UTC time. utc defaults to false to not break behaviour.
This commit is contained in:
@@ -218,10 +218,14 @@ uint64_t OS_Unix::get_unix_time() const {
|
||||
};
|
||||
|
||||
|
||||
OS::Date OS_Unix::get_date() const {
|
||||
OS::Date OS_Unix::get_date(bool utc) const {
|
||||
|
||||
time_t t=time(NULL);
|
||||
struct tm *lt=localtime(&t);
|
||||
struct tm *lt;
|
||||
if (utc)
|
||||
lt=gmtime(&t);
|
||||
else
|
||||
lt=localtime(&t);
|
||||
Date ret;
|
||||
ret.year=1900+lt->tm_year;
|
||||
ret.month=(Month)lt->tm_mon;
|
||||
@@ -231,10 +235,13 @@ OS::Date OS_Unix::get_date() const {
|
||||
|
||||
return ret;
|
||||
}
|
||||
OS::Time OS_Unix::get_time() const {
|
||||
|
||||
OS::Time OS_Unix::get_time(bool utc) const {
|
||||
time_t t=time(NULL);
|
||||
struct tm *lt=localtime(&t);
|
||||
struct tm *lt;
|
||||
if (utc)
|
||||
lt=gmtime(&t);
|
||||
else
|
||||
lt=localtime(&t);
|
||||
Time ret;
|
||||
ret.hour=lt->tm_hour;
|
||||
ret.min=lt->tm_min;
|
||||
|
||||
Reference in New Issue
Block a user