Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
84d060c7
Commit
84d060c7
authored
Dec 20, 2018
by
volzhs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added OS.get_system_time_msecs()
parent
26058376
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
33 additions
and
3 deletions
+33
-3
core_bind.cpp
core/bind/core_bind.cpp
+5
-0
core_bind.h
core/bind/core_bind.h
+1
-0
os.cpp
core/os/os.cpp
+3
-0
os.h
core/os/os.h
+1
-0
OS.xml
doc/classes/OS.xml
+7
-0
os_unix.cpp
drivers/unix/os_unix.cpp
+6
-0
os_unix.h
drivers/unix/os_unix.h
+1
-0
os_windows.cpp
platform/windows/os_windows.cpp
+8
-3
os_windows.h
platform/windows/os_windows.h
+1
-0
No files found.
core/bind/core_bind.cpp
View file @
84d060c7
...
...
@@ -827,6 +827,10 @@ uint64_t _OS::get_system_time_secs() const {
return
OS
::
get_singleton
()
->
get_system_time_secs
();
}
uint64_t
_OS
::
get_system_time_msecs
()
const
{
return
OS
::
get_singleton
()
->
get_system_time_msecs
();
}
void
_OS
::
delay_usec
(
uint32_t
p_usec
)
const
{
OS
::
get_singleton
()
->
delay_usec
(
p_usec
);
...
...
@@ -1182,6 +1186,7 @@ void _OS::_bind_methods() {
ClassDB
::
bind_method
(
D_METHOD
(
"get_datetime_from_unix_time"
,
"unix_time_val"
),
&
_OS
::
get_datetime_from_unix_time
);
ClassDB
::
bind_method
(
D_METHOD
(
"get_unix_time_from_datetime"
,
"datetime"
),
&
_OS
::
get_unix_time_from_datetime
);
ClassDB
::
bind_method
(
D_METHOD
(
"get_system_time_secs"
),
&
_OS
::
get_system_time_secs
);
ClassDB
::
bind_method
(
D_METHOD
(
"get_system_time_msecs"
),
&
_OS
::
get_system_time_msecs
);
ClassDB
::
bind_method
(
D_METHOD
(
"set_icon"
,
"icon"
),
&
_OS
::
set_icon
);
...
...
core/bind/core_bind.h
View file @
84d060c7
...
...
@@ -281,6 +281,7 @@ public:
Dictionary
get_time_zone_info
()
const
;
uint64_t
get_unix_time
()
const
;
uint64_t
get_system_time_secs
()
const
;
uint64_t
get_system_time_msecs
()
const
;
int
get_static_memory_usage
()
const
;
int
get_static_memory_peak_usage
()
const
;
...
...
core/os/os.cpp
View file @
84d060c7
...
...
@@ -61,6 +61,9 @@ uint64_t OS::get_unix_time() const {
uint64_t
OS
::
get_system_time_secs
()
const
{
return
0
;
}
uint64_t
OS
::
get_system_time_msecs
()
const
{
return
0
;
}
void
OS
::
debug_break
(){
// something
...
...
core/os/os.h
View file @
84d060c7
...
...
@@ -328,6 +328,7 @@ public:
virtual
TimeZoneInfo
get_time_zone_info
()
const
=
0
;
virtual
uint64_t
get_unix_time
()
const
;
virtual
uint64_t
get_system_time_secs
()
const
;
virtual
uint64_t
get_system_time_msecs
()
const
;
virtual
void
delay_usec
(
uint32_t
p_usec
)
const
=
0
;
virtual
uint64_t
get_ticks_usec
()
const
=
0
;
...
...
doc/classes/OS.xml
View file @
84d060c7
...
...
@@ -381,6 +381,13 @@
Returns the epoch time of the operating system in seconds.
</description>
</method>
<method
name=
"get_system_time_msecs"
qualifiers=
"const"
>
<return
type=
"int"
>
</return>
<description>
Returns the epoch time of the operating system in milliseconds.
</description>
</method>
<method
name=
"get_ticks_msec"
qualifiers=
"const"
>
<return
type=
"int"
>
</return>
...
...
drivers/unix/os_unix.cpp
View file @
84d060c7
...
...
@@ -202,6 +202,12 @@ uint64_t OS_Unix::get_system_time_secs() const {
return
uint64_t
(
tv_now
.
tv_sec
);
}
uint64_t
OS_Unix
::
get_system_time_msecs
()
const
{
struct
timeval
tv_now
;
gettimeofday
(
&
tv_now
,
NULL
);
return
uint64_t
(
tv_now
.
tv_sec
*
1000
+
tv_now
.
tv_usec
/
1000
);
}
OS
::
Date
OS_Unix
::
get_date
(
bool
utc
)
const
{
time_t
t
=
time
(
NULL
);
...
...
drivers/unix/os_unix.h
View file @
84d060c7
...
...
@@ -84,6 +84,7 @@ public:
virtual
uint64_t
get_unix_time
()
const
;
virtual
uint64_t
get_system_time_secs
()
const
;
virtual
uint64_t
get_system_time_msecs
()
const
;
virtual
void
delay_usec
(
uint32_t
p_usec
)
const
;
virtual
uint64_t
get_ticks_usec
()
const
;
...
...
platform/windows/os_windows.cpp
View file @
84d060c7
...
...
@@ -2142,8 +2142,13 @@ uint64_t OS_Windows::get_unix_time() const {
uint64_t
OS_Windows
::
get_system_time_secs
()
const
{
const
uint64_t
WINDOWS_TICK
=
10000000
;
const
uint64_t
SEC_TO_UNIX_EPOCH
=
11644473600LL
;
return
get_system_time_msecs
()
/
1000
;
}
uint64_t
OS_Windows
::
get_system_time_msecs
()
const
{
const
uint64_t
WINDOWS_TICK
=
10000
;
const
uint64_t
MSEC_TO_UNIX_EPOCH
=
11644473600000LL
;
SYSTEMTIME
st
;
GetSystemTime
(
&
st
);
...
...
@@ -2154,7 +2159,7 @@ uint64_t OS_Windows::get_system_time_secs() const {
ret
<<=
32
;
ret
|=
ft
.
dwLowDateTime
;
return
(
uint64_t
)(
ret
/
WINDOWS_TICK
-
SEC_TO_UNIX_EPOCH
);
return
(
uint64_t
)(
ret
/
WINDOWS_TICK
-
M
SEC_TO_UNIX_EPOCH
);
}
void
OS_Windows
::
delay_usec
(
uint32_t
p_usec
)
const
{
...
...
platform/windows/os_windows.h
View file @
84d060c7
...
...
@@ -254,6 +254,7 @@ public:
virtual
TimeZoneInfo
get_time_zone_info
()
const
;
virtual
uint64_t
get_unix_time
()
const
;
virtual
uint64_t
get_system_time_secs
()
const
;
virtual
uint64_t
get_system_time_msecs
()
const
;
virtual
bool
can_draw
()
const
;
virtual
Error
set_cwd
(
const
String
&
p_cwd
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment