Jump to content

Date conversion w/ GUICtrlCreateDate


mdes
 Share

Recommended Posts

I would like to GUICtrlCreateDate() by displaying the System Long format, BUT GUICtrlRead() in the format yyyy/mm/dd.

So, another way to say: How to convert a system long date format to a format for calculation ?

ps: This should work with "any" locale setting (USA, France,...)

Edited by mdes

Gestion des congés, RTT, vacances scolaires, autres absences sur Pocket PC : CongésRFV

Link to comment
Share on other sites

thought of the macro's yet??

maby i'm wrong bu this should be easy, do you have a example script of ur problem??

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

maby i'm wrong bu this should be easy, do you have a example script of ur problem??

Not so easy, because I don't know the foreign formats:

Saterday, April 14, 2005 ?

Saterday, 14 April 2005 ?

Samedi 14 avril 2005

...

I said: "any" locale setting :( (and not for the current date, but for any date)

Edited by mdes

Gestion des congés, RTT, vacances scolaires, autres absences sur Pocket PC : CongésRFV

Link to comment
Share on other sites

Macro Description

@SEC

Seconds value of clock. Range is 00 to 59

@MIN

Minutes value of clock. Range is 00 to 59

@HOUR

Hours value of clock in 24-hour format. Range is 00 to 23

@MDAY

Current day of month. Range is 01 to 31

@MON

Current month. Range is 01 to 12

@YEAR

Current four-digit year

@WDAY

Numeric day of week. Range is 1 to 7 which corresponds to Sunday through Saturday.

@YDAY

Current day of year. Range is 1 to 366 (or 365 if not a leap year)

this u mean??

p.s. EXAMPLE SCRIPT

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

I restart stating my problem. Here is a sample script:

#include <GUIConstants.au3>

GUICreate ( "My GUI get date", 200,200,800,200)
$date=GUICtrlCreateDate ("2005/01/01", 10,10,185,20 )
GUISetState ()

Do
    $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

$DispDate = GUICtrlRead($date)
$NewDate = "" ;==== What to insert here to transform $DispDate in the yyyymmdd format ? ====

MsgBox(0,"Date", "$DispDate=" & $DispDate & @CR & "$NewDate=" & $NewDate)
GUIDelete()

When running this script, the following GUI is displayed (I want this date format displayed):

Posted Image

And after exiting, the following message box is displayed:

Posted Image

I would like $NewDate to be assigned the value 2005/01/01 (if the user does not change the date).

That's all Folks!

@randallc: @YEAR,... return the current date. What I would like to have is any date in the YYYYMMDD format (or with embedded "/", or "-").

Gestion des congés, RTT, vacances scolaires, autres absences sur Pocket PC : CongésRFV

Link to comment
Share on other sites

I restart stating my problem.  Here is a sample script:

#include <GUIConstants.au3>

GUICreate ( "My GUI get date", 200,200,800,200)
$date=GUICtrlCreateDate ("2005/01/01", 10,10,185,20 )
GUISetState ()

Do
    $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

$DispDate = GUICtrlRead($date)
$NewDate = "";==== What to insert here to transform $DispDate in the yyyymmdd format ? ====

MsgBox(0,"Date", "$DispDate=" & $DispDate & @CR & "$NewDate=" & $NewDate)
GUIDelete()

When running this script, the following GUI is displayed (I want this date format displayed):

Posted Image

And after exiting, the following message box is displayed:

Posted Image

I would like $NewDate to be assigned the value 2005/01/01 (if the user does not change the date).

That's all Folks!

@randallc: @YEAR,... return the current date.  What I would like to have is any date in the YYYYMMDD format (or with embedded "/", or "-").

<{POST_SNAPBACK}>

see example3 in the doc :(
Link to comment
Share on other sites

see example3 in the doc :(

Thanks for your quick reply, but - as I said - I would like to keep the default format displayed "day d mmmm yyyy".

The problem is "How to display a format, but getting back another one?"

Gestion des congés, RTT, vacances scolaires, autres absences sur Pocket PC : CongésRFV

Link to comment
Share on other sites

Thanks for your quick reply, but - as I said - I would like to keep the default format displayed "day d mmmm yyyy".

The problem is "How to display a format, but getting back another one?"

<{POST_SNAPBACK}>

I understand, you need a _datetimeformat working the other way around. Perhaps somebody can write an UDF for that. Remember AutoiT is a wrapper above Windows API somebody can find a solution to this conversion problem and I will be glad to see if we can incorparte it inside AutoIt. :(
Link to comment
Share on other sites

I understand, you need a _datetimeformat working the other way around. Perhaps somebody can write an UDF for that.  Remember AutoiT is a wrapper above Windows API somebody can find a solution to this conversion problem and I will be glad to see if we can incorparte it inside AutoIt. :(

<{POST_SNAPBACK}>

i think you just want to reset the format to leave it the same?

#include <GUIConstants.au3>

GUICreate ( "My GUI get date", 200,200,800,200)

$date=GUICtrlCreateDate ("2005/01/01", 10,10,185,20 )

$Button_OK1  =GUICtrlCreateButton ("&OK",32, 32, 40)

GUISetState ()

while 1

    $msg = GUIGetMsg()

if $msg =$Button_OK1 Then

  displayDate()

  endif

if $msg =$GUI_EVENT_CLOSE Then

  ExitLoop

  endif

WEnd

Exit

func displayDate()

$DispDate = GUICtrlRead($date)

$DTM_SETFORMAT = 0x1005

$style = "yyyy/MM/dd"

GuiCtrlSendMsg($date, $DTM_SETFORMAT, 0, $style)

$NewDate = GUICtrlRead($date)

; reset format

$DTM_SETFORMAT = 0x1005

$style = "dddd, d MMMM yyyy"

GuiCtrlSendMsg($date, $DTM_SETFORMAT, 0, $style)

MsgBox(0,"Date", "$DispDate=" & $DispDate & @CR & "$NewDate=" & $NewDate)

EndFunc

OK?

Randall

Edited by randallc
Link to comment
Share on other sites

i think you just want to reset the format to leave it the same?

OK?

Randall

Thanks a lot, Randall, that's exactly what I wanted :(

somebody can find a solution to this conversion problem and I will be glad to see if we can incorparte it inside AutoIt. :)

Thanks also to jpm for its proposal :( but Randall found it :

Gestion des congés, RTT, vacances scolaires, autres absences sur Pocket PC : CongésRFV

Link to comment
Share on other sites

i think you just want to reset the format to leave it the same?

OK?

Randall

<{POST_SNAPBACK}>

I added one more modification to your Code Randall. It adds the ability to read from the registry the international Long and Short Date.

#include <GUIConstants.au3>
GUICreate ( "My GUI get date", 200,200,800,200)
$date=GUICtrlCreateDate ("2005/01/01", 10,10,185,20 )
$Button_OK1  =GUICtrlCreateButton ("&OK",32, 32, 40)
GUISetState ()

while 1
    $msg = GUIGetMsg()
if $msg =$Button_OK1 Then 
  displayDate()
  endif
if $msg =$GUI_EVENT_CLOSE Then 
  ExitLoop
  endif
WEnd
Exit

func displayDate()
$DispDate = GUICtrlRead($date)
$DTM_SETFORMAT = 0x1005
$style = RegRead( "HKEY_CURRENT_USER\Control Panel\International" , "sShortDate")
GuiCtrlSendMsg($date, $DTM_SETFORMAT, 0, $style)
$NewDate = GUICtrlRead($date)
; reset format
$DTM_SETFORMAT = 0x1005
$style = RegRead( "HKEY_CURRENT_USER\Control Panel\International" , "sLongDate")
GuiCtrlSendMsg($date, $DTM_SETFORMAT, 0, $style)
MsgBox(0,"Date", "$DispDate=" & $DispDate & @CR & "$NewDate=" & $NewDate)
EndFunc

Kerby

Link to comment
Share on other sites

I added one more modification to your Code Randall. It adds the ability to read from the registry the international Long and Short Date.

$style = RegRead( "HKEY_CURRENT_USER\Control Panel\International" , "sShortDate")
I don't agree: "sShortDate" will give "dd/MM/yyyy" or "MM/dd/yyyy" depending on the country; so my application would not be able to process directly the date without analyzing this "sShortDate" :(

But I fully agree to read the Registry for "sLongDate", and in any other case :(

Edited by mdes

Gestion des congés, RTT, vacances scolaires, autres absences sur Pocket PC : CongésRFV

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...