Questions tagged [system-clock]

109 questions
32
votes
6 answers

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

I have just written this short C++ program to approximate the actual number of clock ticks per second. #include #include using namespace std; int main () { for(int i = 0; i < 10 ; i++) { int first_clock =…
Kevin H. Lin
  • 1,158
  • 3
  • 13
  • 16
23
votes
5 answers

Time since first boot up

I'm developing an android application and hit the problem with determining system first boot up time. I mean i need to measure how much time already passed from device first boot up. I know about solution with listening for ACTION_BOOT_COMPLETED and…
user2857033
  • 339
  • 4
  • 6
22
votes
6 answers

JavaScript setTimeout and changes to system time cause problems

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…
Martin Konecny
  • 50,691
  • 18
  • 119
  • 145
20
votes
3 answers

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

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…
Dave A
  • 2,490
  • 9
  • 36
  • 54
18
votes
1 answer

Set Android's date/time programmatically

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);…
eliangela
  • 253
  • 2
  • 5
  • 19
18
votes
4 answers

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

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…
jldeon
  • 323
  • 1
  • 10
11
votes
2 answers

Monotonically increasing time in Node.js

This question has already been answered for the browser here, but window.performance.now() is obviously not available in Node.js. Some applications need a steady clock, i.e., a clock that monotonically increases through time, not subject to system…
Lucio Paiva
  • 13,507
  • 6
  • 71
  • 90
8
votes
1 answer

Accuracy of clock() function in C

I have some code that tries to determine the execution time of a code block. #include #include int main() { clock_t start_t, end_t, total_t; int i; start_t = clock(); //clock start printf("Starting of the program,…
user2808264
  • 409
  • 1
  • 11
  • 21
6
votes
1 answer

Is `System.currentTimeMillis()` correct across multiple processes?

We have a situation where a master process writes to a log. It then spawns multiple worker processes which write to their own logs. (I wanted the workers to log through the master, but there was resistance to this idea for some reason.) What I want…
Trejkaz
  • 10,264
  • 6
  • 52
  • 106
6
votes
2 answers

Android: How to convert from SystemClock.elapsedRealTime to a human readable CharSeq?

How do you convert from SystemClock.elapsedRealTime() to a human readable CharSeq that can be displayed in textview?
user3472351
  • 89
  • 1
  • 2
  • 6
6
votes
2 answers

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

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,…
Aviv Ben Shabat
  • 903
  • 2
  • 12
  • 30
6
votes
1 answer

Google AppEngine server instance clock synchronization

I just came across the following paragraph in the AppEngine documentation for Query Cursors: An interesting application of cursors is to monitor entities for unseen changes. If the app sets a timestamp property with the current date and time…
Markus A.
  • 11,761
  • 8
  • 44
  • 102
6
votes
2 answers

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

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…
Wei Yang
  • 825
  • 3
  • 13
  • 25
6
votes
2 answers

What should Timertask.scheduleAtFixedRate do if the clock changes?

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…
The Archetypal Paul
  • 39,479
  • 18
  • 96
  • 128
6
votes
4 answers

Handling time in a text-based game (Java)

I'm trying to work up a basic text-based game as I'm learning Java. I'd like to be able to count rounds in the game as a means of managing the pacing of certain events. For instance, changing rooms could be limited to once per round (a second, in…
eenblam
  • 438
  • 1
  • 6
  • 19
1
2 3 4 5 6 7 8