I really wanted an
AddMinutes() method to use in javascript like C# has. So I set out to write one myself.
I soon realized how complicated it could get, for instance, the minutes could move the date to the next day, month, or year. I started writing down all the conditions to check, to make sure that I could handle all situations. Since javascript uses the setMinutes(), setHours(), setMonth(), etc.. style of altering a date, I was going to parse the minutes into the number of months, days, hours, and minutes that were represented by the minutes. So 10080 minutes would equal 7 days. After I did that I could add all the appropriate fields and then get my new date.
Then I realized a MUCH easier way to get it done. There is a Date method called
getTime() that returns the number of milliseconds since 1/1/1970. There is also a Date constructor that takes in an integer, which also represents the number of milliseconds since 1/1/1970. So all I had to do was use the getTime() method, convert the minutes that I want to add into milliseconds, add the milliseconds and the create a new date instance with this new value. Much, much easier and I don't have the headache of managing all those situations mentioned above, whew!! Here's the code I used:
function addMinutes(dateTimeObj, iMinutes) {
var length = iMinutes * 60 * 1000;
var iseconds = dateTimeObj.getTime();
iseconds += length;
var dt = new Date(iseconds);
return dt;
}
I'm interested in playing around with the source for .Text, but the source isn't available on GotDotNet anymore.
Does anyone know where I can get a copy? thanks
I declare
Foxy Tunes to be my Firefox extension of the day, this thing is sweet! You can manage a multitude of different players from it, and it shows the current track in the status bar, awesome!
What are other people's favorite extensions?
Frans Bouma reacts to the news that WinFS
will be delayed for 1,989,342 more years
(actually about 2 but it seems longer, doesn't it?). This is too bad, I
was definitely looking forward to such a radical change in the way filesystems
are structured, I think WinFS is terribly intriguing because it appears to be a
complete rework of something that hasn't gotten a whole lot of
attention.
Frans believes that WinFS has been given low priority over
other projects, and I would have to agree. It seems that Microsoft has
done a poor job of PR for this particular project. WinFS was hyped as the
solution to many filesystem woes, notably the ability to search your
hard drive. By telling us that it would be in Longhorn, they set
themselves up for disappointment. Now they say that it won't even make it into
the Longhorn server version slated to be released in '07. Even though
Microsoft can weather the storm that occurs by slipping release dates, this
doesn't help their image, especially among developers and IT
professionals.
Google trumped Microsoft by releasing a desktop
search tool that searched users' hard drives much
better and MUCH faster than the built-in Windows search, and Google didn't need
a new filesystem; it must be embarassing when a competitor improves your own
product better than you can yourself. You can say what you want about
Google's thin web client interface, it gets the job done. Since a huge
goal of WinFS was to improve searching, and then along comes a free search
tool that accomplishes the goal, I'm sure Microsoft had a little priority
rearranging. I think Frans nailed it by asserting that Microsoft had to
react quicker than WinFS would allow them to, and had to release something, thus
the major slippage of WinFS.
At this point, I have to almost wonder if WinFS will ever
come to fruition, or will it go the way of Hailstorm? A lot can change in 2 more
years, and if the tools that are released in '05 are good enough, I think its
possible that we will never see WinFS.