dateitems help

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

wee wullie
Posts: 78
Joined: Fri Oct 03, 2008 10:13 am

forgot this

Post by wee wullie » Sun Oct 12, 2008 6:33 pm

altAnswerDate
This is a free wrapper for Shao Sean'sfine calendarWidget which can be called simply like an answer dialog box. (Thanks again Shao for a great tool!!!!)

To use this stack, make the stack "calendarWidget100" a substack of your main stack. Then when you need to prompt the user for a date, you can put the following into a button script (like the one below):

on mouseUp
put "2006" into tYear
put "8" into tMonth
put "12" into tDay
start using stack "calendarWidget100"
get altAnswerDate(tYear,tMonth,tDay)
stop using stack "calendarWidget100"
if it is empty then exit mouseUp
put it into fld 1
end mouseUp

Note: If you like, you can insert the start using and stop using statements in your startup routine. This will keep the stack loaded in memory. Also, note you can force the calendar to open to a specific date. If you want it to open to today's date, then put "" into tYear, tMonth and tDay.

wee wullie
Posts: 78
Joined: Fri Oct 03, 2008 10:13 am

still no luck

Post by wee wullie » Tue Oct 14, 2008 10:35 am

I've been looking at the output of the altAnswerDate picker and it doesn't seem to be in the regular dateItems format i.e. it only has the: the year, the month number, day of the month and the numeric day of the week , whereas the dateItems format is supposed to be:
* the year
* the month number
* the day of the month
* the hour in 24-hour time
* the minute
* the second
* the numeric day of the week where Sunday is day 1, Monday is day 2, and so forth,

Since this output has only four comma delimited items instead of the usual seven and that they're not in the usual order, is it possible that rev is trying to convert the wrong items and does anyone know if that would make a difference to revs ability to convert it to another date format?.

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Wed Oct 15, 2008 9:38 am

AHA!

Yep, if "the dateitems" are not in the correct/required format, then "convert" will of course fail!

But you could workaround it by adding the missing items manually!
Like 0 for the hour, 0 for the minutes and seconds:

...
put altAnswerDate(tYear,tMonth,tDay) into my_date
put item -1 of my_date into day_of_week
delete item -1 of my_date
put ",0,0,0," & day_of_week after my_date
## NOW my_date is in the correct"dateitems" format
## and you can do whatever you wanted with it
...

Hope that helps.


Best

Klaus

wee wullie
Posts: 78
Joined: Fri Oct 03, 2008 10:13 am

Brilliant!!!

Post by wee wullie » Thu Oct 16, 2008 1:58 am

Klaus, it works a treat, it didn't work with the altAnswerDate var although i may have been missing something, so i tried the following code and it worked perfectly:

put "" into tYear
put "" into tMonth
put "" into tDay
start using stack "calendarWidget100"
get altAnswerDate(tYear,tMonth,tDay)
stop using stack "calendarWidget100"
if it is empty then exit mouseUp
put it into my_date
put item -1 of my_date into day_of_week
delete item -1 of my_date
put ",0,0,0," & day_of_week after my_date
put my_date into fld "Date3"
add 3 to item 1 of my_date
put my_date into fld "Date4"
convert fld "Date3" from dateItems to system date
convert fld "Date4" from dateItems to system date


So thanks Klaus for your expert help and thanks also to Mark and to BvG and everyone who contributed to this thread,
Cheers!!!

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Thu Oct 16, 2008 8:33 am

You're welcome :-)

hamlynart
Posts: 101
Joined: Wed Mar 19, 2008 7:10 pm
Contact:

DateItems

Post by hamlynart » Thu Dec 04, 2008 12:37 am

I'm sorry I didn't see your post sooner - I also ran into the same problem earlier this year and eventually sorted it out by reorganising the result like this:

put "" into tYear
put "" into tMonth
put "" into tDay
start using stack "calendarWidget100"
get altAnswerDate()
stop using stack "calendarWidget100"
if it is empty then exit mouseUp
put it into myT
put item 1 of myT into t4
put item 3 of myT & "/" before line 1 of t4
put item 2 of myT & "/" before line 1 of t4
convert t4 to long english date

Best

Jim

wee wullie
Posts: 78
Joined: Fri Oct 03, 2008 10:13 am

dateItems

Post by wee wullie » Thu Dec 04, 2008 10:19 pm

Hi, thanks for the reply, i got the dateItems problem with my stack sorted out a while ago, but the date picker didn't work with my stack when i ran it in the rev player, i ran it both with my stack and then on its own and got the same problem, so i decided to use the date picker stack by BvG instead which serves the same purpose and i use it as a group within my stack rather than as a substack and it fits the look of my stack better than the altAnswerDate stack,
But thanks for your reply.

Regards
Wee Wullie

FLCo
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 36
Joined: Thu Jul 27, 2006 5:40 am
Contact:

Re: dateitems help

Post by FLCo » Wed Aug 29, 2012 1:48 pm

'DatePicker for LiveCode' has been released and is available from the LiveCode store. It may provide a ready-made solution for you, unless you need to roll your own.

Hugh Senior
FLCo
The Flexible Learning Company
• ChartMaker: www.FlexibleLearning.com/chartmaker
• ControlManager: www.FlexibleLearning.com/controlmanager
• The Scripter's Scrapbook: www.FlexibleLearning.com/ssbk
• DatePicker: www.FlexibleLearning.com/datepicker

Post Reply