Today's Date as an image

Hi

I need to figure out how to find an image that will change each day.
The folder that I need is auto created and is “today’s date”…
aka - 2009-10-15

I know that I can generate a text image - but is there a way to have eggplant determine the date and then auto generate that date as my folder?

I am new to code -but am learning
so any detail about how and why would be most helpful.

thanks for any help -

I am working on both mac and windows… version 3 - but can upgrade to 10 if needed.

thanks
gina

[quote=“binagarry”]Hi

I need to figure out how to find an image that will change each day.
The folder that I need is auto created and is “today’s date”…
aka - 2009-10-15

I know that I can generate a text image - but is there a way to have eggplant determine the date and then auto generate that date as my folder?

I am new to code -but am learning
so any detail about how and why would be most helpful.

thanks for any help -

I am working on both mac and windows… version 3 - but can upgrade to 10 if needed.

thanks
gina[/quote]

Hi Gina–

Eggplant has many functions with regards to dates. today is a pre-defined container that contains today’s date. You can access the properties of the date (the day, month, year, etc) in this way:

put today's day #=> 15

So you can string this into a name the way you want, by putting the parts of the date that you want to use into a list and using the joined by command:

put (today's year, today's month, today's day) joined by "-" into folderName #=> "2009-10-15"

Then you should be able to script your SUT to create or recognize the folder.

As far as I know this should work in v3. I’m sure STDoug will pop in if that’s incorrect.

I highly recommend reading Working With Dates and Times in the SenseTalk Reference in the Eggplant help. Also, don’t hesitate to ask if anything I said was unclear.

Allen

SenseTalk also includes a large number of different date and time formats that are built in. The particular format you’re working with can be accessed as “the international date”:

put the international date -- 2009-10-18

If you want this format for a stored (or calculated) date rather than today’s date, you can get that, too:

put the international date of "7/20/69" -- 1969-07-20

I am trying to use your examples to change my scripts from “opening the calender and clicking the OK button (to get todays date)” to your examples above.

Here is my code that I have to test this;
Click “BeginningLeaveDate”
TypeText
put today’s day #=> “2009-11-12”

I get in the field the value 12, which is today’s date, but how do I get it in this format? 11/12/2009

Any ideas? I checked out the Reference Manual and could not find anything is there other resources with this information?

Thanks
m

Information on dates and times can be found in the SenseTalk Reference manual in the chapter “Working with Dates and Times”.

Remarkably, the format you’re looking for (with a four-digit year) isn’t among the built-in date formats available. You can get that format in a couple of ways. For one-time use, you can use the formattedTime() function:

put formattedTime("%m/%d/%Y")

If you’d like to make this your standard date format, you can change the built-in format at the beginning of your script run like this:

set the timeFormat.date to "%m/%d/%Y"

From then on any time you call the date() function you’ll get the date with a four-digit year:

put the date -- 11/12/2009

Thanks Worked like a charm. Here is the Code that I used, not sure if this is the best way to do this;

set the timeFormat.date to “%m/%d/%y” at the beginning of the script

Click “LOA_Field_Click”
put the date
TypeText date

10/13/09 was then entered into the field.

Thanks

Actually, you’ve got more code there than you need. The change to timeFormat.date in my earlier example was just to achieve the four-digit year that you showed in your earlier post. If a two-digit year in the date works fine in your application then you don’t need to change the format at all, just call the date function:

Click "LOA_Field_Click" 
TypeText the date 

IMPORTANT: Be sure to use “the date” or “date()” rather than just “date” to call the date function. The fact that the word “date” by itself calls the date function in the current version of Eggplant is due to a mistake in the SenseTalk compiler, so it may not work the same in future versions when that mistake is corrected. Using “the date” will ensure that your script will always work.

Will do. You said that the code you gave me was for the four digit year. I noticed what is typed into the field is on a two digit year but our application does change it to four digit if I set focus out of that field. When I watch the text type into the field it looks like this 11/13/09. Do you think it is because I did not have “the date” and only the word “date”?

No, the difference is the “%y” (2-digit year) versus “%Y” (4-digit year) in the format. The standard setting of timeFormat.date is “%m/%d/%y” which gives the 2-digit year (11/13/09).

If you need Eggplant to type the date with the full year, as “11/13/2009” you’ll need to change the format. But it sounds like your application is accepting dates entered with a 2-digit year, so you should be fine without changing the format.