diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/bind/core_bind.cpp | 22 | ||||
-rw-r--r-- | core/bind/core_bind.h | 5 | ||||
-rw-r--r-- | core/os/os.h | 12 |
3 files changed, 28 insertions, 11 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 128bc94989..26b1dac6f1 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -457,9 +457,9 @@ void _OS::set_icon(const Image& p_icon) { OS::get_singleton()->set_icon(p_icon); } -Dictionary _OS::get_date() const { +Dictionary _OS::get_date(bool utc) const { - OS::Date date = OS::get_singleton()->get_date(); + OS::Date date = OS::get_singleton()->get_date(utc); Dictionary dated; dated["year"]=date.year; dated["month"]=date.month; @@ -470,9 +470,9 @@ Dictionary _OS::get_date() const { } -Dictionary _OS::get_time() const { +Dictionary _OS::get_time(bool utc) const { - OS::Time time = OS::get_singleton()->get_time(); + OS::Time time = OS::get_singleton()->get_time(utc); Dictionary timed; timed["hour"]=time.hour; timed["minute"]=time.min; @@ -480,6 +480,15 @@ Dictionary _OS::get_time() const { return timed; } + +Dictionary _OS::get_time_zone_info() const { + OS::TimeZoneInfo info = OS::get_singleton()->get_time_zone_info(); + Dictionary infod; + infod["bias"] = info.bias; + infod["name"] = info.name; + return infod; +} + uint64_t _OS::get_unix_time() const { return OS::get_singleton()->get_unix_time(); @@ -774,8 +783,9 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_cmdline_args"),&_OS::get_cmdline_args); ObjectTypeDB::bind_method(_MD("get_main_loop"),&_OS::get_main_loop); - ObjectTypeDB::bind_method(_MD("get_date"),&_OS::get_date); - ObjectTypeDB::bind_method(_MD("get_time"),&_OS::get_time); + ObjectTypeDB::bind_method(_MD("get_date","utc"),&_OS::get_date,DEFVAL(false)); + ObjectTypeDB::bind_method(_MD("get_time","utc"),&_OS::get_time,DEFVAL(false)); + ObjectTypeDB::bind_method(_MD("get_time_zone_info"),&_OS::get_time_zone_info); ObjectTypeDB::bind_method(_MD("get_unix_time"),&_OS::get_unix_time); ObjectTypeDB::bind_method(_MD("set_icon"),&_OS::set_icon); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 05f54dd64c..74f29c23e8 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -204,8 +204,9 @@ public: void set_use_file_access_save_and_swap(bool p_enable); void set_icon(const Image& p_icon); - Dictionary get_date() const; - Dictionary get_time() const; + Dictionary get_date(bool utc) const; + Dictionary get_time(bool utc) const; + Dictionary get_time_zone_info() const; uint64_t get_unix_time() const; int get_static_memory_usage() const; diff --git a/core/os/os.h b/core/os/os.h index 2f9957c2f8..0230a75ca0 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -244,9 +244,15 @@ public: int min; int sec; }; - - virtual Date get_date() const=0; - virtual Time get_time() const=0; + + struct TimeZoneInfo { + int bias; + String name; + }; + + virtual Date get_date(bool local=false) const=0; + virtual Time get_time(bool local=false) const=0; + virtual TimeZoneInfo get_time_zone_info() const=0; virtual uint64_t get_unix_time() const; virtual void delay_usec(uint32_t p_usec) const=0; |