time

Get week start timestamp and week end timestamp using Java SE API and Joda Time (based on ISO)

How may I get week start timestamp (2010-03-01 00:00:00 UTC) and week end timestamp (2010-03-08 00:00:00 UTC) given a java.util.Date (or Joda DateTime), or year and ISO week number, using Java SE API and Joda Time? ...

Convert durations in Ruby - hh:mm:ss.sss to milliseconds and vice versa

Hey there, I was wondering if there is a built-in method in Ruby that allows me to convert lap times in the format of hh:mm:ss.sss to milliseconds and vice versa. Since I need to do some calculations with it, I assumed that converting to milliseconds would be the easiest way to do this. Tell me if I am wrong here :) Cheers, Chris ...

Date/time conversion problem if moment is exactly at end of wintertime (non-DST)

In my application I need to calculate shifts using a pattern described in a file. Recently, at one of my customers the application was hanging because of the following reason: If you fill in a 'struct tm' with the exact moment at the end of the wintertime (non-DST) _mktime seems to return an incorrect result. The code looks like this: ...

Measure upload time?

I have a very simple page with which a user uploads a file. Using only server-side C# (e.g. the code-behind), how can I measure the amount of time the user had to wait for the file to upload? ...

Subtracting a certain number of hours, days, months or years from date

Hi, I'm trying to create a simple function which returns me a date with a certain number of subtracted days from now, so something like this but I dont know the date classes well: <? function get_offset_hours ($hours) { return date ("Y-m-d H:i:s", strtotime (date ("Y-m-d H:i:s") /*and now?*/)); } function get_offset_days ($days) { ...

Writing extra code to avoid learning new frameworks

I am a one-man shop at the place where I work, and when I started there I had zero experience and a BS degree from a below-par school of Computer Science. On top of that, my first project at the company involved not just figuring out good design principles, it also involved learning a new language. Needless to say, my code was crappy in ...

Retrieve time from the internet (bypassing PC clock)?

For my MFC/C++ unmanaged time-limited software needs, I'd like to get a GMT/UTC time-stamp from the internet (instead of relying on the PC clock time that can be easily changed). I already though about parsing the line "Current UTC"... line from http://www.timeanddate.com/worldclock/ (I think port 80 is more likely to be open than other...

Alternative of struct tm

Does there exist any other alternative data structure instead of struct tm (having same memory allocated as this structure) ? So that I could use strftime without declaring <time.h> I am aware of the fact that relying on implicit declaration is not good,but I faced this question in an interview. EDIT: To be precise I was asked to print...

How to compute number of seconds since the beginning of this day?

I want to get the number of seconds since midnight. Here is my first guess: time_t current; time(&current); struct tm dateDetails; ACE_OS::localtime_r(&current, &dateDetails); // Get the current session start time const time_t yearToTime = dateDetails.tm_year - 70; // year to 1900 converted into year to 1970 const t...

Get POSIX/Unix time in seconds and nanoseconds in Python?

I've been trying to find a way to get the time since 1970-01-01 00:00:00 UTC in seconds and nanoseconds in python and I cannot find anything that will give me the proper precision. I have tried using time module, but that precision is only to microseconds, so the code I tried was: import time print time.time() which gave me a result ...

Why time.clock() returns such a large value on Windows Server 2008 X64

I ran following script on different machine and got quite different results. The elapsed time.clock() is so large. Script: #------------------------------------------------------------------------------------ import time start_clock = time.clock() time.sleep(60) end_clock = time.clock() print "Sleep Clock = ", str(end_clock - start_cl...

How to check if datetime is older than 20 seconds.

Hello! This is my first time here so I hope I post this question at the right place. :) I need to build flood control for my script but I'm not good at all this datetime to time conversions with UTC and stuff. I hope you can help me out. I'm using the Google App Engine with Python. I've got a datetimeproperty at the DataStore database w...

Calculation Conundrum - how do I influence another textfield?

Hey! Basically I have a problem in that when certain parameters are used in my calculator app - it makes the result incorrect. The issue is that I have separate text fields for hours and minutes and say for example I have as the start time "13" in one text field and "30" in the other with the finish time "24" and "00" in their respectiv...

How to change a sound playing start time in objective-c?

I would like to play a sound in Objective-C with a millisecond start time. I know it is possible this way but "currentTime" only takes seconds: currentPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil]; currentPlayer.currentTime = 100; Is there a way to set the start time with milliseconds? ...

Time based VBA script for exercises

I have an excel spreadsheet with two columns, one with a list of exercises (33 of them) and a number of reps for each. What I really want is a program that picks a random exercise, displays it with it's number of reps, and has a button that says something like "Done?" When you click it, I want a timer that counts down 20 minutes, picks a...

How do I convert a number to hours and minutes?

Hey guys, I got help with correct calculation the other day but I've hit a block about how to implement it into code. -(IBAction)done:(id)sender { int result = (([startHours.text intValue] * 60) + [startMinutes.text intValue]) - (([finishHours.text intValue] * 60) + [finishMinutes.text intValue]); totalHours.text = [NSString str...

How to align times by their colon in a LaTeX-tabular?

I have a tabular of the times I in LaTeX. These times are in the form 4:00 or 12:00 and this have different lengths. I would like to vertically align these times by their colon. Is there a nice way to do this in LaTeX? ...

Factoring in night shifts to a working hours calculator.

OK, Thanks to all of you that have helped with my quandry. However, there is one stumbling block - I need to factor in night shifts. For example, if the start time is 13h and the finish time is 2h - I want it to come up as 15h, not 11h. This is the code: -(IBAction)done:(id)sender { int result = (([startHours.text intValue] * 60) ...

Adding up time durations in Python

I would like to add up a series of splits in Python. The times begin as strings like "00:08:30.291". I can't seem to find the right way to use the Python objects or API to make this convenient/elegant. It seems that the time object doesn't use microseconds, so I'm using datetime's strptime to parse the strings, successfully. But then dat...

How to programatically convert a time from one timezone to another in C?

The info pages for the GNU date command contains this example: For example, with the GNU date command you can answer the question "What time is it in New York when a Paris clock shows 6:30am on October 31, 2004?" by using a date beginning with `TZ="Europe/Paris"' as shown in the following shell transcript: $ export TZ="...