4 Replies Latest reply on Dec 4, 2006 4:18 AM by Newsgroup_User

# Using Lingo to count days

Hi everybody!

I need to be able to count days... for example:

I want to know how many days until Christmas....

I tried using BudAPI, get todays month and day and subtract that number from
1225 (Christmas.) However, if it is the 26th of December or the first of
January, my calculations do not work correctly.

Any quick and easy solutions to this?

Thanks!

• ###### 1. Re: Using Lingo to count days
Hi,

In lingo - you can use a date object like this:

today = the systemDate
xmas = date(today.year, 12, 24)
daystoChristmas = (xmas - today)

If you have Director MX2004, you can use Javascript and calculate how many milliseconds to go like this

today = new Date();
xmas = new Date(today.getUTCFullYear(), 11, 24); // note month is 0-11
howLong = xmas.getTime() - today.getTime()

-- Luke
• ###### 2. Re: Using Lingo to count days
quote:

Originally posted by: Newsgroup User
However, if it is the 26th of December or the first of
January, my calculations do not work correctly.

You just need to check the date when deciding on which christmas to calculate for. See the code attached below.
Hope this helps!

- Ben

• ###### 3. Re: Using Lingo to count days
Thank you!

"Lukewig" <webforumsuser@macromedia.com> wrote in message
news:el0cof\$235\$1@forums.macromedia.com...
> Hi,
>
> In lingo - you can use a date object like this:
>
> today = the systemDate
> xmas = date(today.year, 12, 24)
> daystoChristmas = (xmas - today)
>
> If you have Director MX2004, you can use Javascript and calculate how
many
> milliseconds to go like this
>
> today = new Date();
> xmas = new Date(today.getUTCFullYear(), 11, 24); // note month is 0-11
> howLong = xmas.getTime() - today.getTime()
>
>
> -- Luke
>

• ###### 4. Re: Using Lingo to count days
Thanks! This code works perfectly!

J

"duckets" <webforumsuser@macromedia.com> wrote in message
news:el0vbf\$n83\$1@forums.macromedia.com...
>
quote:

Originally posted by: Newsgroup User
> However, if it is the 26th of December or the first of
> January, my calculations do not work correctly.
>

>
> You just need to check the date when deciding on which christmas
to
> calculate for. See the code attached below.
> Hope this helps!
>
> - Ben
>
>
>
>
> today = the systemDate
> xmas = date(today.year, 12, 24)
> if (today > xmas) then
> xmas = date(today.year+1, 12, 24)
> end if
> daystoChristmas = (xmas - today)
>