Jump to content


Photo

Help with a countdown that is far away


  • Please log in to reply
5 replies to this topic

#1 Rino

Rino
  • Members
  • 198 posts

Posted 14 April 2012 - 07:22 PM

My fiance wants me to have a script that tells her how many days till her and my wedding. I am aware their are several scripts out there for a countdown. But I want to compare how far away it is in days from whatever time it is currently to December 8th, 2012. This is what I have now some of it I know is wrong I'm just not sure how to go about it since I don't generally deal with formatting time.

q::

FormatTime, wedding, 201212081500 


Formattime, %timeleft%, CurrentDate
FormatTime, today, CurrentDateTime

timeleft:=%wedding%-%today%

Msgbox, %wedding% is our wedding date and it is currently %today% the time left is %timeleft%
sleep, 60000
exitapp
;



#2 maul.esel

maul.esel
  • Members
  • 790 posts

Posted 14 April 2012 - 08:55 PM

W := 20121208150000 ; the wedding date



; some formatting for display:

FormatTime today,, LongDate

FormatTime wedding, %W%, LongDate



; now calculate the difference in days:

EnvSub W, %A_Now%, Days ; EnvSub is capable of calculating time units



; Display:

MsgBox %W% days left from today (%today%) to wedding (%wedding%).


#3 G. Sperotto

G. Sperotto
  • Members
  • 467 posts

Posted 14 April 2012 - 09:10 PM

Hi Rino.

Welcome to the AutoHotkey community forums.


The help files on EnvSub seem to have a suitable example to serve as a guideline for your project.

EnvSub, MyCount, 2
MyCount -= 2 ; Equivalent to above

var1 = 20050126
var2 = 20040126
EnvSub, var1, %var2%, days
MsgBox, %var1% ; The answer will be 366 since 2004 is a leap year.


<!-- m -->http://www.autohotke...ands/EnvSub.htm<!-- m -->

To find the current date in the same format as in the example, simply declare the variable to hold the current date like this:

CurrentDate := A_YYYY . A_MM . A_DD

Or like this:

CurrentDate = %A_YYYY%%A_MM%%A_DD%

And good luck on the big day :wink:

#4 Leef_me

Leef_me
  • Moderators
  • 7704 posts

Posted 14 April 2012 - 09:29 PM

Congrats to you, condolences to you fiance :wink: Just kidding there.

The reason why your script wasn't working is that the formattime command converts the date to a format
that people understand, but your timeleft calculation fails because AHk doesn't understand that format.
Also, there is no 'CurrentDate' variable; the closest is 'a_now'

The other user's already gave you sufficient information but I just had to chime in too

This one is for the bachelor chaps in your crowd.
Don't let the mis' see this one or you won'y need the script at all. :)
weddate=201212081500 
daysleft := weddate
daysleft -= %a_now%, days

hoursleft := weddate
hoursleft -= %a_now%, hours

minutesleft := weddate
minutesleft -= %a_now%, minutes

secondsleft := weddate
secondsleft -= %a_now%, seconds

FormatTime, wedding, %weddate%
FormatTime, today, a_now

Msgbox, 
(
Our wedding date is %wedding%
and since it is currently %today%
the time left is %daysleft% days

That's only %hoursleft% hours of freedom
That's only %minutesleft% minutes of freedom
That's only %secondsleft% seconds of freedom
)


#5 0x150--ISO

0x150--ISO
  • Members
  • 657 posts

Posted 14 April 2012 - 10:44 PM

just get 1of these and replace the globe with a collage of ur life.
Posted Image
Kissinger not included ;) joking

#6 Rino

Rino
  • Members
  • 198 posts

Posted 15 April 2012 - 03:28 AM

Thanks for your help I am sure she will be quite pleased.