time

Java's currentTimeMillis returns negative value(s)

Hello, I'm developing a simple 2D game in Java, everything works fine. To find the correct FPS refresh/redraw/update, I used currentTimeMillis to find the difference. The problem is that currentTimeMillis sometimes returns negative values, and the Thread.sleep will throw exception (java.lang.IllegalArgumentException: timeout value is n...

alternative for waitForPageToLoad in Selenium

I have a series of links on a page that take different times to load... I want to capture the amount of time each takes... The problem I am having is that the waitForPageToLoad time if exceeded causes the test to fail and the rest of my links do not get tested... I know I could just skip suspected links in the test or set the time limit...

Manipulation of Time in VC++

how to calculate the starting and end time of switch in VC++ can anyone please help me to solve this? ...

Checking Run time in IntelliJ IDEA

How can I see how much time it took for the code to run in InteliJ? ...

How can I time my C program?

I looked through old threads but could not find the answer to my question: How can I time the body of my function inside a C program? ...

page load time with Jquery

I want to calculate the page load time; This means from second 0 (a little jquery snippet was loaded) to second x, when the whole page is loaded. i wonder if any one had an experience with it, also ideas how to implement it correctly will be apperciated. please i don't need an extension, i already have firebug, i need a js solution th...

Ruby unit testing: how to fake Time.now?

What's the best way to set Time.now for the purpose of testing time-sensitive methods in a Unit test? Thanks! ...

Possible? Use Google Maps/GPS to tell how long someone has been in a location?

I'm thinking about building an iphone app that would use the GPS feature to track where someone is and for how long. I realize I could probably get the current location from the iphone from a website but the only way I'm familiar with is using ajax calls, etc (Sorry if this is a rather newbie concept) but I fear that would bog down my s...

manipulate current time in unit testing?

Is there any way to manipulate the current time in a jUnit 4.5 test? I have the following method which I'd like to have a unit test for public String getLastWeek() { GregorianCalendar c = new GregorianCalendar(TimeZone.getTimeZone("Europe/Stockholm")); c.setFirstDayOfWeek(GregorianCalendar.MONDAY); c.add(GregorianCalendar.WEEK_OF...

Construct PHP strings to time from XML

I'm trying to convert the following XML into a Time: <time hour="18" minute="05" timezone="Eastern" utc-hour="-4" utc-minute="00" /> I'm parsing the XML using SimpleXML, and storing that in a class. I also tried printing out the following: print strtotime($x->time->attributes()->hour . ":" . $x->time->attributes()->minute) . "<br>\...

More precise distance_of_time_in_words

distance_of_time_in_words is great, but sometimes it's not granular enough. I need a function that will report exact distances of time in words. E.g., 7:50AM to 10:10AM should be a distance of "2 hours and 20 minutes", not "about 2 hours" or whatever distance_of_time_in_words would do. My use case is reporting train schedules, and in p...

Indexing an array every cycle (in seconds)

I have to put datas every 10 seconds in an array. Is it silly to index this array with modified timestamps $a[timestamp] = 54; $a[timestamp+10] = 34; or in Javascript with the setInterval() and passing via Ajax the index (very crappy to me) ? or have I a best option ? Further details : I have to link the real-time with entries in...

How Does the Network Time Protocol Work?

The Wikipedia entry doesn't give details and the RFC is way too dense. Does anyone around here know, in a very general way, how NTP works? I'm looking for an overview that explains how Marzullo's algorithm (or a modification of it) is employed to translate a timestamp on a server into a timestamp on a client. Specifically what mechanism...

How do I format a date to mm/dd/yyyy in Ruby?

In Perl you can do: my $current_time = DateTime->now(); my $mdy = $current_time->mdy("/"); What's the easiest way to do this in Ruby? ...

Outputting Time - a DateTime entry

Related: This is a continuation from my earlier question, Wrong Logic in If Statement? $repeat_times = mysql_real_escape_string($repeat_times); $result = mysql_query("SELECT `code`,`datetime` FROM `fc` ORDER by datetime desc LIMIT 25") or die(mysql_error()); $output .=""; $seconds = time() - strtotime($fetch_array["datetime"]); ...

Wrong logic in If Statement?

$repeat_times = mysql_real_escape_string($repeat_times); $result = mysql_query("SELECT `code`,`datetime` FROM `fc` ORDER by datetime desc LIMIT 25") or die(mysql_error()); $output .=""; $seconds = time() - strtotime($fetch_array["datetime"]); if($seconds < 60) $interval = "$seconds seconds"; else if($seconds < 3600) $interval ...

PHP's strtotime() in Java?

I'm looking for an easy way to generate a MySQL DATETIME from any type of time input a user may enter. PHP makes it easy with its strtotime() function that can do: strtotime(’2004-02-12T15:19:21+00:00′); strtotime(’Thu, 21 Dec 2000 16:01:07 +0200′); strtotime(’Monday, January 1st’); strtotime(’tomorrow’); strtotime(’-1 week 2 days 4...

How do I break down an NSTimeInterval into year, months, days, hours, minutes and seconds on iPhone?

I have a time interval that spans years and I want all the time components from year down to seconds. My first thought is to integer divide the time interval by seconds in a year, subtract that from a running total of seconds, divide that by seconds in a month, subtract that from the running total and so on. That just seems convoluted ...

Is this set of time constants correct or is there a better built-in source in Cocoa

For working with time interval calculations on iPhone and looking at some component values. #define kSecondsInYear 31556926 #define kSecondsInMonth 2629744 #define kSecondsInDay 86400 #define kSecondsInHour 3600 #define kSecondsInMinute 60 I got these from Google's conversion function. I rounded Seconds in Month to nearest int. ...

Now() Accuracy in VBScript

Now() in VBScript appears to return time in 10,000,000th of a second precision when called as CDbl(Now()). In attempting to use this to write a more accurate implementation of now which returns CIM_DATETIME format I found that in VBScript, despite being particularly precise, is not very accurate with the time only updating once per secon...