View Full Version : Working with dates
Magellan
07-28-2006, 07:56 PM
Hi. I'm currently working on on particular project and i'm stuck in what i'll tell you right now.
I'd like to get my system date and if the date correspond to a particular date, show the corresponding page.
For exemple:
I'd like the page "love" to show on the 15 of august. Then, it continues.. The page "Work" would show on the 16 of august... so on.
How can i do that ?
Thanks!
Intrigued
07-28-2006, 08:19 PM
Put these on the page you want to start with:
On Preload
Page.StartTimer(1000)
On Timer
-- Date is in the form of MM/DD/YYYY
strDate = System.GetDate(DATE_FMT_US)
-- Change the date (keep the double-quotes) to what you need
if strDate == "07/28/2006" then
Page.Jump("Page2")
end
Magellan
07-28-2006, 09:43 PM
That was fast ! Thanks Intrigued.
Can i ask you what is the timer for ?
I'll try this tomorow morning right after wake up ! :) :yes
Intrigued
07-28-2006, 10:12 PM
When thinking of timers remember that in AMS (and other programming languages for that matter) 1000ms (milliseconds) equals 1 second.
I turned the timer on with the Page.StartTimer() Action and as an argument I put 1000ms (1 second). Then in the On Timer anything in that page will "fire" (take place) each second.
Just remember to set the Page.StartTimer() (can turn it off with Page.StopTimer() by the way) outside of the On Timer event area.
This is a good way to have Actions happen at predetermined time intervals.
Becareful when using the On Timer area. Sometimes it's better to place code differently. For example, instead of setting up a time and guessing when a Webpage would load in a Web Object and then have some Action(s) take place. It would be better to use the Web Objects On Load for such. Thus when the Webpage loads fully, then and only then will those Actions take place.
I hope this helps explain such a bit better.
Magellan
07-29-2006, 12:44 PM
Thas does explain a little more yes. I'm not a programmer and the knowlodge i get from programming is gain through AMS. Thanks for your time !
If i may, i'd like to ask you another question... Could it be possible to only use days and months, excluding the years ?
yosik
07-29-2006, 01:54 PM
If you'd read the help file, you'd see that you can use various arguments for your date:
DATE_FMT_US
0
North American (MM/DD/YYYY)
DATE_FMT_EUROPE
1
European (DD/MM/YYYY)
DATE_FMT_ISO
2
ISO Date (YYYY-MM-DD)
DATE_FMT_JULIAN
3
Julian Date (an integer value representing the number of days since midnight on January 1, 4713 B.C.)
DATE_FMT_MONTH
4
Month (MM)
DATE_FMT_DAY
5
Day (DD)
DATE_FMT_YEAR
6
Year (YYYY)
DATE_FMT_DAYOFWEEK
7
Day of the week (1-7)
Yossi
Magellan
07-29-2006, 02:39 PM
Thank you Yosik, but i'v already read the help file and it seems that i can't have a month and day format only. It's either the month or the day, but not both. My question is : is it possible to do what i want with those two separated formats ?
yosik
07-29-2006, 02:59 PM
Yes it is. You just have to concatenate the two:
System.GetDate(DATE_FMT_DAY)..System.GetDate(DATE_ FMT_MONTH)
(you can add anything in between, before or after).
Good luck
Yossi
Magellan
07-29-2006, 03:26 PM
Ok ! I'll try this ! Thanks for your help ! :cool
Magellan
07-29-2006, 09:17 PM
That's working great ! :)
I have a last request to ask you, if you don't mind. I'd like to know how to show a particular page during a range of dates. For exemple, i'd like to show the page love during month 05 day 01 to month 05 day 06.
I tried the "or" but it doesn't work well. I'm sure there is a better way to work this out. :yes
Thanks again for your time and help.
Magellan
07-29-2006, 11:20 PM
Ok i just found it... but i'd like to know what you would've done !
I did : if nombre >= 0321 and nombre <= 0325 then
Page.Jump ..........
Intrigued
07-30-2006, 12:09 AM
Take at look over at lua.org for findpattern() (all lower-case)
Here is a link to get you to what you need:
http://lua-users.org/wiki/PatternsTutorial
Intrigued
07-30-2006, 12:40 AM
Looks like AMS 6 does not support findpattern(). Sorry there. I'll add it to the suggestion box for the next version.
Magellan
07-30-2006, 10:07 AM
I guess that luapattern is a way to search for a string right ?
Last night, i forgot to tell you that i used the String.ToNumber function so i could work with numbers instead of strings.
Thanks for your help anyway Intrigued. :yes
Intrigued
07-30-2006, 10:12 AM
Np. I went ahead and put this suggestion (findpattern()) in the Suggestion forum nontheless.
:yes
Magellan
07-30-2006, 12:57 PM
The better it gets, the happier i get too ! ;)
yosik
07-30-2006, 04:16 PM
It is one way of doing things and as we all say: " if it works, don't change it".
So...WAY TO GO!!
Yossi
Magellan
07-30-2006, 09:36 PM
Thanks Yosik ! ;)
Don't forget DateDiff Plugin (its free).
http://www.indigorose.com/forums/showthread.php?t=12737
Makes working with dates a lot easier IMO.
Magellan
07-31-2006, 07:47 AM
That's Great Worm ! At that time i only use the tranparency dll but i'm sure gonna have a look to other plugins out there. Thanks for you idea !
:)
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.