My daughter loves christmas. She often asks me, "how long is it till christmas?" The problem with that is that I'm one of those people that can barely remember what year it is much less the date. Well, it is one thing to be a flawed person and its another thing to disappoint your daughter. Monad to the rescue!
Here is a little date math routine I wrote to help me out:
function tillXmas (){ $now = [DateTime]::Now [Datetime]("12/25/" + $now.Year) - $Now}
MSH> tillxmas
Days : 321Hours : 18Minutes : 8Seconds : 26Milliseconds : 171Ticks : 277997061718750TotalDays : 321.755858470775TotalHours : 7722.14060329861TotalMinutes : 463328.436197917TotalSeconds : 27799706.171875TotalMilliseconds : 27799706171.875
Thanks to Monad, I can tell my daughter how many seconds to go till Xmas! Now if I can only get her to stop asking me in the car.
Here is an exercise for you - calculate what time I ran this example (hint - think "date math" and use the Ticks value)
Enjoy!
Jeffrey P. SnoverMonad Architect
[Edit: Monad has now been renamed to Windows PowerShell. This script or discussion may require slight adjustments before it applies directly to newer builds.]