time

Elapsed time without considering weekends and bank holidays in Java

I've implemented a stopwatch that works fine without considering that bank holidays and weekends shouldn't be counted in the total duration. I was looking for some open-source library where I could get the elapsed time, passing a start instant, end instant and a set of bank holidays (weekends aren't counted in). The only library that mak...

time.sleep -- sleeps thread or process?

In Python for the *nix, does time.sleep() block the thread or the process? ...

calculate elapsed time in flash

I am building a quiz and i need to calculate the total time taken to do the quiz. and i need to display the time taken in HH::MM::SS..any pointers? ...

How do I convert a date/time to epoch time (aka unix time -- seconds since 1970) in Perl?

Given a date/time as an array of (year, month, day, hour, minute, second), how would you convert it to epoch time, i.e., the number of seconds since 1970-01-01 00:00:00 GMT? Bonus question: If given the date/time as a string, how would you first parse it into the (y,m,d,h,m,s) array? ...

Unix gettimeofday() - compatible algorithm for determining week within month?

If I've got a time_t value from gettimeofday() or compatible in a Unix environment (e.g., Linux, BSD), is there a compact algorithm available that would be able to tell me the corresponding week number within the month? Ideally the return value would work in similar to the way %W behaves in strftime() , except giving the week within the...

Python - easy way to add N seconds to a datetime.time?

Given a datetime.time value in Python, is there a standard way to add an integer number of seconds to it, so that 11:34:59 + 3 = 11:35:02, for example? These obvious ideas don't work: >>> datetime.time(11, 34, 59) + 3 TypeError: unsupported operand type(s) for +: 'datetime.time' and 'int' >>> datetime.time(11, 34, 59) + datetime.timede...

Best way to store event times in (My)SQL database

I'm trying to decide on the best way to store event times in a MySQL database. These should be as flexible as possible and be able to represent "single events" (starts at a certain time, does not necessarily need an end time), "all day" and "multi day" events, repeating events, repeating all day events, possibly "3rd Saturday of the mont...

Serializing DateTime to time without milliseconds and gmt

I have created a C# class file by using a XSD-file as an input. One of my properties look like this: private System.DateTime timeField; [System.Xml.Serialization.XmlElementAttribute(DataType="time")] public System.DateTime Time { get { return this.timeField; } set { this.timeField = value; } } ...

convert timestamp to alphanum

I have an application where an user has to remember and insert an unix timestamp like 1221931027. In order to make it easier to remember the key I like to reduce the number of characters to insert through allowing the caracters [a-z]. So I'm searching for an algorithm to convert the timstamp to a shorter alphanum version and do the same ...

How do I convert between time formats?

I am looking to convert a mysql timestamp to a epoch time in seconds using php, and vice versa. What's the cleanest way to do this? ...

Convert mysql timestamp to epoch time in python

Convert mysql timestamp to epoch time in python - is there an easy way to do this? ...

Storing a calendar day in sqlite database

I need to store items with a calendar date (just the day, no time) in a sqlite database. What's the best way to represent the date in the column? Julian days and unix seconds come to mind as reasonable alternatives. If I go with a unit other than days at what clock time should it be? Update: I am aware of ISO8601 and actually used it...

Calculate client-server time difference in Borland Starteam server 8

Problem. I need a way to find Starteam server time through Starteam Java SDK 8.0. Version of server is 8.0.172 so method Server.getCurrentTime() is not available since it was added only in server version 9.0. Motivation. My application needs to use views at specific dates. So if there's some difference in system time between client (whe...

How accurate can I expect the time to be from a stratum 0 NTP server on the same subnet on ethernet?

I have an application that depends on gpsd and ntpd to accurately set the system time on a linux machine. gpsd is fed NMEA + PPS The application is punping ~25MB per second over the network and I think the loading on the system is causing jitter in the time somehow. (loaded PCI express bus causing irregular interrupt latency) I have a...

How do you calculate accumulative time in C#?

I want to calculate the time span between 2 times which I saved in a database. So literally I want to know the length of time between the 2 values. 14:10:20 - 10:05:15 = 02:05:05 So the result would be 02:05:05. How would I be able to achieve this using C#? 14:10:20 is the format I saved it in in my database. ...

how do i read a time value and then insert it into TimeSpan variables

how do i read a time value and then insert it into TimeSpan variables ...

How do I set a task to run every so often?

How do I have a script run every, say 30 minutes? I assume there are different ways for different OSs. I'm using OS X. ...

What is the best way of storing time?

What is the best way to store time ? There seem to be a lot of ways to handle this. Wikipedia has a listing, but most of them are epoch based. What if you were an archaeologist and wanted to store a date in your program? ...

php check for a valid date, weird date conversions

Is there a way to check to see if a date/time is valid you would think these would be easy to check: $date = '0000-00-00'; $time = '00:00:00'; $dateTime = $date . ' ' . $time; if(strtotime($dateTime)) { // why is this valid? } what really gets me is this: echo date('Y-m-d', strtotime($date)); results in: "1999-11-30", huh? i ...

What is the best way to parse a time into a Date object from user input in Javascript?

I am working on a form widget for users to enter a time of day into a text input (for a calendar application). Using JavaScript (we are using jQuery FWIW), I want to find the best way to parse the text that the user enters into a JavaScript Date() object so I can easily perform comparisons and other things on it. I tried the parse() met...