timespan

ActionScript 3.0 + Calculate timespan between two dates?

我怕爱的太早我们不能终老 提交于 2019-11-27 07:52:30
In ActionScript 3.0, is there an automatic way to calculate the number of days, hours, minutes and seconds between two specified dates? Basicly, what I need is the ActionScript equivalent of the .NET Timespan class. Any idea? I created an ActionScript TimeSpan class with a similar API to System.TimeSpan to fill that void, but there are differences due to the lack of operator overloading. You can use it like so: TimeSpan.fromDates(later, earlier).totalDays; Below is the code for the class (sorry for the big post - I won't include the Unit Tests ;) /** * Represents an interval of time */ public

What are timer ticks, the unit used by Stopwatch.ElapsedTicks

浪子不回头ぞ 提交于 2019-11-27 07:38:18
问题 I used to think that Stopwatch.ElapsedTicks was equal to Stopwatch.Elapsed.Ticks . But it isn't. While the latter is a number of 100 nanoseconds periods, the former use a mysterious unit called timer ticks . I wonder what those are, and why are they different from the usual unit of measurement? 回答1: From the docs: The Stopwatch measures elapsed time by counting timer ticks in the underlying timer mechanism. If the installed hardware and operating system support a high-resolution performance

How to Convert string “07:35” (HH:MM) to TimeSpan

被刻印的时光 ゝ 提交于 2019-11-27 07:35:57
I would like to know if there is a way to convert a 24 Hour time formatted string to a TimeSpan. Right now I have a "old fashion style": string stringTime = "07:35"; string[] values = stringTime.Split(':'); TimeSpan ts = new TimeSpan(values[0], values[1], 0); While correct that this will work: TimeSpan time = TimeSpan.Parse("07:35"); And if you are using it for validation... TimeSpan time; if (!TimeSpan.TryParse("07:35", out time)) { // handle validation error } Consider that TimeSpan is primarily intended to work with elapsed time, rather than time-of-day. It will accept values larger than 24

Get envelope.i.e overlapping time spans

旧街凉风 提交于 2019-11-27 07:28:51
问题 I have a table with online sessions like this (empty rows are just for better visibility): ip_address | start_time | stop_time ------------|------------------|------------------ 10.10.10.10 | 2016-04-02 08:00 | 2016-04-02 08:12 10.10.10.10 | 2016-04-02 08:11 | 2016-04-02 08:20 10.10.10.10 | 2016-04-02 09:00 | 2016-04-02 09:10 10.10.10.10 | 2016-04-02 09:05 | 2016-04-02 09:08 10.10.10.10 | 2016-04-02 09:05 | 2016-04-02 09:11 10.10.10.10 | 2016-04-02 09:02 | 2016-04-02 09:15 10.10.10.10 | 2016

JavaScriptSerializer not deserializing DateTime/TimeSpan Properly

懵懂的女人 提交于 2019-11-27 07:28:40
问题 Having a problem where DateTime/TimeSpan doesn't seem to deserialize properly with JavaScriptSerializer. When I get the Object back after deserializing the TimeSpan is empty and if I use DateTime then the times are all out of whack. Did find this article but it didn't really help me too much. http://www.west-wind.com/weblog/ShowPost.aspx?id=471402 Anyone have any ideas? Should I maybe try the json.net library? public class JsonFilter : ActionFilterAttribute { public string Param { get; set; }

Calculate Years, Months, weeks and Days

扶醉桌前 提交于 2019-11-27 06:19:21
问题 In my application, a user enters two dates. A scheduled start date, and a scheduled end date. We have to take those dates, and populate 4 fields, based on the difference. So, lets say he selects 1st Jan, 2010 as a start, and 2nd of March, 2011 as the end, we need to end up with: Years: 1 Months: 2 Weeks: 0 Days 1 Meaning the total duration is 1 year, 2 months and 1 day. Is there a standard way of doing this? Or would I need to write a method that has a lot of pretty tricky logic to work it

Convert .NET Ticks to SQL Server DateTime

陌路散爱 提交于 2019-11-27 04:51:50
I am saving a TimeSpan (from .NET) value in my db as BIGINT in SQL Server (saving the Ticks property). I want to know how to convert this BIGINT value to a DATETIME value in SQL Server (not in .NET). Any ideas? Cheers EDIT: I am using NHibernate to map a TimeSpan property I have, and it persists the Ticks property. I use it for relative hours (or minutes) control over some date. Internally in the system everything is fine, this conversion isn't needed. However, when performing random queries in SQL Server, it is hard to understand the persisted form of a TimeSpan . So, a function where I pass

Do we have a TimeSpan sort of class in Java

北战南征 提交于 2019-11-27 04:44:07
I was just wondering if there is a need of TimeSpan in java.util so that I can define how much hours,minutes and seconds are there in between these two times. From this TimeSpan we can have a time interval between two times. like TimeSpan getTimeSpan( Date before, Date after ){...} or long timeSpan = System.currentTimeMillis(); // ... long job timeSpan = System.currentTimeMillis() - timeSpan; TimeSpan ts = new TimeSpan(timeSpan); and with this TimeSpan we can use it in SimpleDateFormat . SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss"); format.format( timsSpan ); I am not sure if

Check if datetime instance falls in between other two datetime objects

℡╲_俬逩灬. 提交于 2019-11-27 04:20:33
I would like to know a simple algorithm to check if the given instance of datetime lies between another two instances in C# . Note: I skimmed though this How do I check if a given datetime object is "between" two datetimes? and it was for python and many more for php. Most of the other questions were regarding difference between the two. Details: I am more specific about the time, date does not matter to me. For example i got DataBase entry for a staff who works between 10:00 Am - 9:00 Pm and me as principal[for example] would like to know which staff is engaged in class at the given time like

Getting time span between two times in C#?

有些话、适合烂在心里 提交于 2019-11-27 03:52:30
I have two textboxes. One for a clock in time and one for clock out. The times will be put in this format: Hours:Minutes Lets say I have clocked in at 7:00 AM and clocked out at 2:00 PM. With my current code, I get a difference of 2 hours, but it should be 7 hours. How would I do that in C#. I was going to convert to the 24 hour, by letting the user select AM or PM, but I got confused. So, basically, how would I calculate the difference of hours between the two times? I tried this, but got 2 hours and not 7 when I plugged in the numbers. DateTime startTime = Convert.ToDateTime(textBox1.Text);