Frozen on November Fourth

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
NZN37
Posts: 8
Joined: Sat Apr 14, 2007 8:12 pm

Frozen on November Fourth

Post by NZN37 » Mon Mar 19, 2012 10:40 pm

I want some code which lists days in order:

on mouseUp
put empty into fld test
put "10/31/12" into temp
repeat with zz=1 to 6
convert temp to seconds
add 86400 to temp
convert temp to short date
put temp into line zz of fld test
end repeat
end mouseUp

But the thing hangs on 11/4/12 and repeats that date indefinitely.
What gives??

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Frozen on November Fourth

Post by bn » Mon Mar 19, 2012 11:20 pm

Hi NZN37,

apparently you live in a country that reverts from daylight saving time on Nov fourth. The night is one hour longer and you are stuck on that date because of your data/seconds conversions. 86400 will not be enough to go to the next day on that day. (where I live it is Oct 28th)

I just changed your code a bit:

Code: Select all

on mouseUp
   put empty into fld test
   put "10/26/12" into temp
   convert temp to seconds
   repeat with zz=1 to 16
      put temp into temp2
      convert temp2 to short date
      put temp2 into line zz of fld test
      add 86400 to temp
   end repeat
end mouseUp
Kind regards
Bernd

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Frozen on November Fourth

Post by dunbarx » Tue Mar 20, 2012 2:34 am

Well done Bernd.

The way around this of course is to add 1 to item 3 of the dateItems.

Did I mention that it was well done?

Craig Newman

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Frozen on November Fourth

Post by bn » Tue Mar 20, 2012 9:31 am

Hi Craig,

thank you. But unfortunately my solution was not well done. It ran into the same problem I was describing. When daylight saving ends the day has 90.000 seconds. I did not take that into account. It gives the ending date twice. :oops:
(I did test the code but overlooked this)

Here is a solution with dateItems

Code: Select all

on mouseUp
      put empty into fld test
      put "10/26/12" into temp
      convert temp to dateItems
      repeat with zz=1 to 16
            put temp into temp2
            convert temp2 to short date
            put temp2 into line zz of fld test
            add 1 to item 3 of  temp
      end repeat
end mouseUp
sorry for the confusion and thank you Craig for bringing this up again.

If you want to stick to adding 86400 seconds you would have to start from noon. That is what Sarah Reichelt recomends.

Code: Select all

on mouseUp
   put empty into fld test
   put "12:00" into tNoon
   put "10/26/12" && tNoon into temp
   convert temp to seconds
   repeat with zz=1 to 16
      put temp into temp2
      convert temp2 to short date
      put temp2 into line zz of fld test
      add 86400 to temp
   end repeat
end mouseUp
Craig's suggestion to use dateItems is definitely the way to go.

Kind regards

Bernd

Post Reply