If a train leaves less than an hour from now, I want its row in the schedule table to be highlighted red. Currently I'm doing the calculation like this:
if Time.zone.now + 1.hour > t[from_station]
# do whatever
end
This works and kind of makes sense, but I wonder if there's a clearer / more idiomatic way to express this (I could ima...
I need to kill the "yes" command after some iterations, two methods:
a) kill it
b) give "n" as an input
after some time
How would you automate the removal of .git directory?
...
In a recent question, someone asked if they could make a time just using the hour, minute, and AM/PM parts of a standard time format. This led to my question, what is needed to create a time using strtotime?
Do you need to have a date? If one is not provided, what date does it choose?
Do you need to have a time? What is the default?
Do...
I'm new to Hibernate and am working with an Oracle 10g database. We have columns in our tables that are of type TIMESTAMP WITH TIMEZONE. Hibernate does not seem to support this mapping directly. Is there a standard way to go about this?
Thanks
...
How can I force the Time.rfc2822 function to spit out +0000?
Ruby lets me parse RFC2822 formatted times pretty easily:
require 'time'
time = Time.parse('14 Aug 2009 09:28:32 +0000')
puts time
=> "2009-08-14 05:28:32 -0400"
But what about displaying times? Notice that the time it parsed is a local time. No worries, I can convert it ...
I have run into an issue that is probably due to my mis-understanding of how the DateTime.ToShortTimeString() method works. When formatting time strings with this function, I was assuming that it would respect the "Short Time" setting in Windows 7's Format settings
Control Panel -> Clock, Language and Region -> Region and Language -> Fo...
Simple C question, how can I correctly and succintly convert milliseconds to seconds.
There are two constraints:
I've no floating point support in this tiny subset-of-C compiler
I need the seconds rounded to the nearest second(1-499ms rounds down,500-999ms rounds up. Don't need to care about negative values)
int mseconds = 1600; // sh...
I'm using the Last.fm API and I stuck on something seemingly fairly simple.
One of the responses is the duration. Which is returned as:
222000
But how do I format (in PHP) this to look like
MIN:SEC
3:42
...
I want to know how long a command takes to run. At the moment I am doing this:
echo | time | find "current" & dowahdiddy.exe & echo | time | find "current"
Which shows me the time before and after:
The current time is: 11:39:14.38
...dowahdiddy output...
The current time is: 11:39:15.44
I have to determine the difference. I could p...
I am building a SCORM 2004 javascript API for an LMS, and one of the SCORM 2004 requirements is that timeintervals passed into it must follow the following format. Does anyone know what the regular expression of this would be? I am trying to wrap my mind around it, but to no avail. Note: P must always be the first character.
P[yY]...
How to run function 5 seconds after pygtk widget is shown?
...
Following on from this question...I'm trying to unit test the following scenario:
I have a class that allows one to call a method to perform some action and if it fails wait a second and recall that method.
Say I wanted to call a method DoSomething()...but in the event of an exception being thrown by DoSomething() I want to be able to...
Hey guys - The problem stems from a poorly designed database used to store real estate information. I set up a template for my client to select a weekend and to display the open houses for that weekend. Open house times (ohtime1, ohtime2, ohtime3) are stored as tinytext, with no way of knowing AM or PM. "12:00 - 2:00" and "01:00 - 03:00"...
I'm building a event calendar and pass a start time to PHP, in the format of 2009-09-25 15:00:00. A duration gets passed as well, that might be in the format of 60 minutes or 3 hours. Converting from hours to minutes isn't the problem. How do you add a length of time to an established starting point to correctly format the end time?
...
I'm working with a database that has date information stored as a Unix timestamp ( int(11) ) and what I want to do is only return entries from the past X days, the past 90 days for example.
What I've come up with is:
SELECT * FROM mytable WHERE category=1 AND
FROM_UNIXTIME( time ) > DATE_SUB(now(), INTERVAL 91 DAY)
Where 'time' is t...
Hello
Assume I have 2 time intervals,such as 16:30 - 20:00 AND 15:00 - 19:00, I need to find the total time between these two intervals so the result is 5 hours (I add both intervals and subtract the intersecting interval), how can I write a generic function which also deals with all cases such as one interval inside other(so the result ...
So this was one of my very first questions here, but I have a slight variation:
So I have two people whose schedules are in a database. The schedules simply record the start time, end time, and description of the various events/appointments for both users.
PersonA wants to trade appointments with PersonB. I want a MySQL query that will...
I have two programs written in C++ that use Winsock. They both accept TCP connections and one sends data the other receives data. They are compiled in Visual Studio 2008. I also have a program written in C# that connects to both C++ programs and forwards the packets it receives from one and sends them to the other. In the process it coun...
I'm just wondering ..
I have and object like this
public class Entry{
public DateTime? Date { get; set;} // This is just Date
public DateTime? StartTime { get; set; } //This is just Time
public TimeSpan Duration { get; set; } //Time spent on entry
}
Is there a more appropriate type than DateTime or better strategy to handling j...
Is TIME used in F# Units of Measure?
...