system-clock

JavaScript setTimeout and changes to system time cause problems

喜欢而已 提交于 2019-12-03 11:06:03
问题 I've noticed that if I set the setTimeout for 1 minute in the future, and then change my system time to 5 minutes in the past, the setTimeout function will trigger in 6 minutes. I did this is because I wanted to see what happens during a daylight savings change to the system clock. My JavaScript webpage uses a setTimeout function to automatically refresh the page every 5 seconds, and if daylight savings were to occur, then the page information would freeze for an hour. Is there a workaround?

JavaScript setTimeout and changes to system time cause problems

最后都变了- 提交于 2019-12-03 01:31:32
I've noticed that if I set the setTimeout for 1 minute in the future, and then change my system time to 5 minutes in the past, the setTimeout function will trigger in 6 minutes. I did this is because I wanted to see what happens during a daylight savings change to the system clock. My JavaScript webpage uses a setTimeout function to automatically refresh the page every 5 seconds, and if daylight savings were to occur, then the page information would freeze for an hour. Is there a workaround? Edit: I am updating the page using Ajax, I dont want to refresh the entire page. Siedrix What I will do

Set Android's date/time programmatically

匆匆过客 提交于 2019-11-30 13:00:02
问题 I need set the date/time from Android programmatically, but I'm not having success! I have these three sources above: Source code 1 AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE); alarm.setTime(1330082817000); AndroidManifest: <uses-permission android:name="android.permission.SET_TIME" /> <uses-permission android:name="android.permission.SET_TIME_ZONE" /> Exception: Service fatal error : Unable to start activity ComponentInfo{br.com.tdta.service/br.com.tdta.service

Is there an NTP server I should be using when using Amazon's EC2 service to combat clock drift?

北城以北 提交于 2019-11-30 08:15:38
I’m using AWS and am on an EC2 server … [dalvarado@mymachine ~]$ uname -a Linux mydomain.org 3.14.33-26.47.amzn1.x86_64 #1 SMP Wed Feb 11 22:39:25 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux My clock is off by a minute ro so despite the fact that I already have NTPD installed and running [dalvarado@mymachine ~]$ sudo service ntpd status ntpd (pid 22963) is running... It would appear ntp packets are blocked or there is some other problem because I get this error … [dalvarado@mymachine ~]$ sudo ntpdate pool.ntp.org 2 Apr 16:43:50 ntpdate[23748]: no server suitable for synchronization found Does

Set Android's date/time programmatically

*爱你&永不变心* 提交于 2019-11-30 06:40:38
I need set the date/time from Android programmatically, but I'm not having success! I have these three sources above: Source code 1 AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE); alarm.setTime(1330082817000); AndroidManifest: <uses-permission android:name="android.permission.SET_TIME" /> <uses-permission android:name="android.permission.SET_TIME_ZONE" /> Exception: Service fatal error : Unable to start activity ComponentInfo{br.com.tdta.service/br.com.tdta.service.Service}: java.lang.SecurityException: setTime: Neither user 10038 nor current process has android.permission

How do I deal with the system clock changing while waiting on a std::condition_variable?

穿精又带淫゛_ 提交于 2019-11-29 17:08:29
问题 I'm trying to implement some cross-platform code in C++11. Part of this code implements a semaphore object using a std::condition_variable. When I need to do a timed wait on the semaphore, I use wait_until or wait_for. The problem I'm experiencing is that it seems like the standard implementation of condition_variable on POSIX-based systems relies on the system clock, rather than the monotonic clock (see also: this issue against the POSIX spec) That means that if the system clock gets changed

How to get Android system uptime and realtime from command line?

泄露秘密 提交于 2019-11-29 07:21:49
I'm writing a script containing several "adb shell" command. I also want to record the time when program execute these command in a form of realtime and uptime. I know I can get uptime and realtime through SystemClock: SystemClock.uptimeMillis(); SystemClock.elapsedRealtime(); Is there any way I can get these information from the command line? Thanks a lot! Try: adb shell cat /proc/uptime If you only need to-the-second accuracy, adb shell uptime will also work. Example output: up time: 00:09:26, idle time: 00:07:15, sleep time: 00:00:00 来源: https://stackoverflow.com/questions/18135966/how-to

Android - Get current time without dependency on device's clock

廉价感情. 提交于 2019-11-28 02:01:25
I've noticed that System.currentTimeMillis() time is device dependent. If I change the time on the device's clock, this method will return a different answer. For example: If the real time now is 10:00, and I change the clock on my device to 9:30, then System.currentTimeMillis() will return the 9:30 time (in milliseconds..). I've also tried this answer and some other answers, but didn't find anything useful. I should state that my app works mostly offline. Is there a way to get the real current time (device independent) without external API? If it were not for the 'offline' part, I'd have

What should Timertask.scheduleAtFixedRate do if the clock changes?

巧了我就是萌 提交于 2019-11-27 14:52:51
We want to run a task every 1000 seconds (say). So we have timer.scheduleAtFixedRate(task, delay, interval); Mostly, this works fine. However, this is an embedded system and the user can change the real time clock. If they set it to a time in the past after we set up the timer, it seems the timer doesn't execute until the original real-time date/time. So if they set it back 3 days, the timer doesn't execute for 3 days :( Is this permissible behaviour, or a defect in the Java library? The Oracle javadocs don't seem to mention anything about the dependency or not on the underlying value of the

Why is CLOCKS_PER_SEC not the actual number of clocks per second?

允我心安 提交于 2019-11-27 04:04:24
I have just written this short C++ program to approximate the actual number of clock ticks per second. #include <iostream> #include <time.h> using namespace std; int main () { for(int i = 0; i < 10 ; i++) { int first_clock = clock(); int first_time = time(NULL); while(time(NULL) <= first_time) {} int second_time = time(NULL); int second_clock = clock(); cout << "Actual clocks per second = " << (second_clock - first_clock)/(second_time - first_time) << "\n"; cout << "CLOCKS_PER_SEC = " << CLOCKS_PER_SEC << "\n"; } return 0; } When I run the program, I get output that looks like this. Actual