PDA

View Full Version : Days till Christmas



sandyrepope
15-08-2007, 00:34
I wanted a quick way to keep up with how many day there are until Christmas so I came up with this script.

uses "ui"
uses "dt"

dim S as string 'holds the current date
dim Christmas as string = "12-25-2007" 'Christmas date
dim week_day_name as string 'Holds week day name as string
dim Number_Of_Days as long 'number of days till christmas

s = date$ 'get the current date

week_day_name = dt_getweekdayname(dt_getweekday(S), %dt_use_long_form)

Number_Of_Days = dt_Datediff(s, Christmas, %DT_DIFF_IN_DAYS) 'get number of days till christmas

'report gathered information

msgbox 0, "Today: " _
+ s _
+ $crlf _
+ "Days until Christmas: " _
+ Number_Of_Days _
+ $crlf _
+ "Which is on a " + week_day_name


Hope someone else can use it too.
Thanks
Sandy

Michael Hartlef
15-08-2007, 05:54
Thanks, my son could use it.

kryton9
15-08-2007, 07:08
182 days till I can drop a hint for a new video card :) Thanks!

Michael Hartlef
15-08-2007, 07:44
I can drop hints as much as I want to. My wallet says no and my notebook espercially says no. :D

Petr Schreiber
15-08-2007, 09:01
;D

This is useful script, I did similar to see when school ends, but then it started to make me nervous as days were decrementing slowly :)


Thanks,
Petr

sandyrepope
15-08-2007, 16:04
I hate to say this but there seems to be a problem with the script. I've been running it more and it seems that it doesn't always return the correct number of days and doesn't always report the correct day of the week for Christmas. I don't know if this is just on my computer or if there is a problem with the module.

Could anyone check to see:

How many days does it give on your machine.

Does it always say that Christmas is on a Tuesday.

I suspect that there is a problem with the separator. In s what does your machine use.

I'll keep checking and report what I find out.
Thanks
Sandy

sandyrepope
15-08-2007, 16:23
I found a mistake in my script. I used the wrong variable for getting the day of the week for Christmas. Here is a corrected version.

uses "ui"
uses "dt"

dim S as string 'holds the current date
dim Christmas as string = "12-25-2007" 'Christmas date
dim week_day_name as string 'Holds week day name as string
dim Number_Of_Days as long 'number of days till christmas

s = date$ 'get the current date

week_day_name = dt_getweekdayname(dt_getweekday(Christmas), %dt_use_long_form)

Number_Of_Days = dt_Datediff(s, Christmas, %DT_DIFF_IN_DAYS) 'get number of days till christmas

'report gathered information

msgbox 0, "Today: " _
+ s _
+ $crlf _
+ "Days until Christmas: " _
+ Number_Of_Days _
+ $crlf _
+ "Which is on a " + week_day_name


On my machine it gives the correct information but a comment from Kryton9 makes me wonder if it could be not giving the correct results on other machines.

182 days till I can drop a hint for a new video card
On my machine it says that there are only 132 days till Christmas. I ran the script on the 15th of August.
Thanks
Sandy

Petr Schreiber
15-08-2007, 16:27
Thanks for the fix !

it works ok now, I got the same number of days but other day for first version of the scipt.


Thanks,
Petr

kryton9
15-08-2007, 20:17
Thanks for the fix Sandy!

Petr Schreiber
15-08-2007, 21:13
Hi,

I now leave till Saturday ( for real :( ), to check if the day of return has come use this mod of sandys script :D:


uses "dt"

dim S as string 'holds the current date
dim DateOfReturn as string = "08-18-2007" 'Christmas date
dim week_day_name as string 'Holds week day name as string
dim Number_Of_Days as long 'number of days till christmas

s = date$ 'get the current date

week_day_name = dt_getweekdayname(dt_getweekday(DateOfReturn), %dt_use_long_form)

Number_Of_Days = dt_Datediff(s, DateOfReturn, %DT_DIFF_IN_DAYS) 'get number of days till christmas

'report gathered information

if Number_Of_Days <= 0 then
msgbox 0, "I AM BACK! TBGL wheels are turning again :)"
else
msgbox 0, "Psch is currently not nearby computer, leave a message :)"+$CRLF+$CRLF+"He will return on "+DateOfReturn+", which is "+week_day_name
endif


Bye and have a nice time,
Petr

P.S. UI module is not neccessary for MSGBOX, it is native part of Core.

Michael Hartlef
15-08-2007, 22:44
Have a good time Petr.

Michael Clease
16-08-2007, 01:22
thanks for the idea.

this is a TBGL version.

new version that looks a bit better.

kryton9
16-08-2007, 03:25
:) the seconds are flying by, great alternative idea! Thanks.

Michael Hartlef
16-08-2007, 13:34
Hey cool, I like that one!

Michael Clease
16-08-2007, 13:44
I updated the file so it provides more information.

ErosOlmi
18-08-2007, 18:53
Thanks gui!
What about a more general script?
Change this:



dim Christmas as string value "12-25-2007" 'Christmas date



to this:



dim Christmas as string value "12-25-" & dt_year(date$) 'Christmas date

kryton9
18-08-2007, 22:38
You are the thinBasic Guru for a reason Eros, great!!