From 6f9a084ac8a820450632f17384161c6a24da86d3 Mon Sep 17 00:00:00 2001 From: Maximillian Date: Thu, 6 Aug 2015 10:29:33 -0700 Subject: Add OS.get_system_time_msec --- drivers/unix/os_unix.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers/unix/os_unix.cpp') diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index f6d9e0fb4..1afd0be61 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -223,6 +223,13 @@ uint64_t OS_Unix::get_unix_time() const { return time(NULL); }; +uint64_t OS_Unix::get_system_time_msec() const { + struct timeval tv_now; + gettimeofday(&tv_now, null); + uint64_t msec = tv_now.tv_.sec / 1000; + return msec; +} + OS::Date OS_Unix::get_date(bool utc) const { -- cgit v1.2.3-70-g09d2 From 6b25e83ba73ae3321aff00d7b3192d8cd80c410c Mon Sep 17 00:00:00 2001 From: xodene Date: Thu, 6 Aug 2015 11:08:48 -0700 Subject: tested and fixed unix os_system_time_msec() --- drivers/unix/os_unix.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/unix/os_unix.cpp') diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 1afd0be61..314e13cee 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -225,8 +225,9 @@ uint64_t OS_Unix::get_unix_time() const { uint64_t OS_Unix::get_system_time_msec() const { struct timeval tv_now; - gettimeofday(&tv_now, null); - uint64_t msec = tv_now.tv_.sec / 1000; + gettimeofday(&tv_now, NULL); + localtime(&tv_now.tv_usec); + uint64_t msec = tv_now.tv_usec/1000; return msec; } -- cgit v1.2.3-70-g09d2 From 69710055f0af99838d669b2e3fa3f1ae8bf6683d Mon Sep 17 00:00:00 2001 From: Mavhod Date: Thu, 13 Aug 2015 14:09:21 +0700 Subject: get_date on Linux tm_mon is 0-11--- drivers/unix/os_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/unix/os_unix.cpp') diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 314e13cee..ba151b0f4 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -242,7 +242,7 @@ OS::Date OS_Unix::get_date(bool utc) const { lt=localtime(&t); Date ret; ret.year=1900+lt->tm_year; - ret.month=(Month)lt->tm_mon; + ret.month=(Month)lt->tm_mon + 1; ret.day=lt->tm_mday; ret.weekday=(Weekday)lt->tm_wday; ret.dst=lt->tm_isdst; -- cgit v1.2.3-70-g09d2 From 3942117bbf1b669fb81628bb401d16ad83f1f2bb Mon Sep 17 00:00:00 2001 From: Mavhod Date: Thu, 13 Aug 2015 18:56:13 +0700 Subject: add () Sorry, firt time I put it but had no compiled for check.--- drivers/unix/os_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/unix/os_unix.cpp') diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index ba151b0f4..975affbb8 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -242,7 +242,7 @@ OS::Date OS_Unix::get_date(bool utc) const { lt=localtime(&t); Date ret; ret.year=1900+lt->tm_year; - ret.month=(Month)lt->tm_mon + 1; + ret.month=(Month)(lt->tm_mon + 1); ret.day=lt->tm_mday; ret.weekday=(Weekday)lt->tm_wday; ret.dst=lt->tm_isdst; -- cgit v1.2.3-70-g09d2 From e3e93da6b94cdf14e9a6f466cf5f50a857166928 Mon Sep 17 00:00:00 2001 From: Ariel Manzur Date: Wed, 9 Sep 2015 20:24:38 +0000 Subject: fixed localtime thing for ios, not tested anywhere else --- drivers/unix/os_unix.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/unix/os_unix.cpp') diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 314e13cee..05af7ee90 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -226,7 +226,8 @@ uint64_t OS_Unix::get_unix_time() const { uint64_t OS_Unix::get_system_time_msec() const { struct timeval tv_now; gettimeofday(&tv_now, NULL); - localtime(&tv_now.tv_usec); + //localtime(&tv_now.tv_usec); + localtime((const long *)&tv_now.tv_usec); uint64_t msec = tv_now.tv_usec/1000; return msec; } -- cgit v1.2.3-70-g09d2 From fad1faddae96454bbe4abfef1bf394b3d2c9c057 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 10 Sep 2015 13:10:23 -0300 Subject: Removing locatime so this function compiles again. I don't think it has any practical use anyway. --- drivers/unix/os_unix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/unix/os_unix.cpp') diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 05af7ee90..96f90e6be 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -227,8 +227,8 @@ uint64_t OS_Unix::get_system_time_msec() const { struct timeval tv_now; gettimeofday(&tv_now, NULL); //localtime(&tv_now.tv_usec); - localtime((const long *)&tv_now.tv_usec); - uint64_t msec = tv_now.tv_usec/1000; + //localtime((const long *)&tv_now.tv_usec); + uint64_t msec = uint64_t(tv_now.tv_sec)*1000+tv_now.tv_usec/1000; return msec; } -- cgit v1.2.3-70-g09d2