Sign in to follow this  
Followers 0
Snarg

Date conversion

5 posts in this topic

Greetings fellow AutoIt users. I have what would seem to be a simple problem. I would like to read in the date a script was started to an .ini file. This is easy enough. I would like to also display this date in a SplashText window. I can do that to, no problem.

The problem I am having is converting the %A_WDAY% from a number to an actual day of the week. This is what I have tried:

IfEqual, A_WDAY, 1, SetEnv, A_WDAY, Sunday

It still displays the day of the week as a number. Any help would be greatly appreciated. Thank you.


A little reading goes a long way. Post count means nothing.

Share this post


Link to post
Share on other sites



shouldn't it be:

IfEqual, A_WDAY, 1, SetEnv, S_WDAY, Sunday

IfEqual, A_WDAY, 2, SetEnv, S_WDAY, Monday

then display %S_WDAY%

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Perfect! Thank you very much.


A little reading goes a long way. Post count means nothing.

Share this post


Link to post
Share on other sites

Ok, I think I have this correct. Would someone take a look at it and let me know if I did anything wrong? Thank you.

SetEnv, RunDate, %A_WDAY%: %A_HOUR%:%A_MIN%
;Get the current date/time

IfLessOrEqual, A_HOUR, 11, SetEnv, AM_PM, AM
IfGreaterOrEqual, A_HOUR, 12, SetEnv, AM_PM, PM
;Soon to be used for display purposes

IfEqual, A_WDAY, 1, SetEnv, S_WDAY, Sunday
IfEqual, A_WDAY, 2, SetEnv, S_WDAY, Monday
IfEqual, A_WDAY, 3, SetEnv, S_WDAY, Tuesday
IfEqual, A_WDAY, 4, SetEnv, S_WDAY, Wendsday
IfEqual, A_WDAY, 5, SetEnv, S_WDAY, Thrusday
IfEqual, A_WDAY, 6, SetEnv, S_WDAY, Friday
IfEqual, A_WDAY, 7, SetEnv, S_WDAY, Saturday
;Change a number to an actual day

IfEqual, A_HOUR, 00, SetEnv, S_HOUR, 0
IfEqual, A_HOUR, 01, SetEnv, S_HOUR, 1
IfEqual, A_HOUR, 02, SetEnv, S_HOUR, 2
IfEqual, A_HOUR, 03, SetEnv, S_HOUR, 3
IfEqual, A_HOUR, 04, SetEnv, S_HOUR, 4
IfEqual, A_HOUR, 05, SetEnv, S_HOUR, 5
IfEqual, A_HOUR, 06, SetEnv, S_HOUR, 6
IfEqual, A_HOUR, 07, SetEnv, S_HOUR, 7
IfEqual, A_HOUR, 08, SetEnv, S_HOUR, 8
IfEqual, A_HOUR, 09, SetEnv, S_HOUR, 9
IfEqual, A_HOUR, 10, SetEnv, S_HOUR, 10
IfEqual, A_HOUR, 11, SetEnv, S_HOUR, 11
IfEqual, A_HOUR, 12, SetEnv, S_HOUR, 12
IfEqual, A_HOUR, 13, SetEnv, S_HOUR, 1
IfEqual, A_HOUR, 14, SetEnv, S_HOUR, 2
IfEqual, A_HOUR, 15, SetEnv, S_HOUR, 3
IfEqual, A_HOUR, 16, SetEnv, S_HOUR, 4
IfEqual, A_HOUR, 17, SetEnv, S_HOUR, 5
IfEqual, A_HOUR, 18, SetEnv, S_HOUR, 6
IfEqual, A_HOUR, 19, SetEnv, S_HOUR, 7
IfEqual, A_HOUR, 20, SetEnv, S_HOUR, 8
IfEqual, A_HOUR, 21, SetEnv, S_HOUR, 9
IfEqual, A_HOUR, 22, SetEnv, S_HOUR, 10
IfEqual, A_HOUR, 23, SetEnv, S_HOUR, 11
;Change from a 24 hour clock to a normal, human clock

SplashTextOn, 200, 100, Script Staus, Script started on: %S_WDAY%: %S_HOUR%:%A_MIN%%AM_PM%
;Finaly, display when the script started

A little reading goes a long way. Post count means nothing.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Ok, I think I have this correct. Would someone take a look at it and let me know if I did anything wrong? Thank you.

Looks fine to me...

Just 1 minor remarks:

- you could save some lines by replacing the 24 hour IF statements with something like:

SetEnv, S_HOUR, %A_HOUR%

IfGreater, S_HOUR, 12, EnvSub,S_HOUR, 12

IfLess, S_HOUR, 10, StringTrimLeft, S_HOUR , S_HOUR, 1

Jos

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0