date format

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

date format

pablo digonzelli
I want to create a Presenter who manages a date value in format
'dd/mm/yyyy'.
Otherwise I want a Date view who is in sync with this presenter.
I do not know how can i do.
Can someone help me?
TIA


Reply | Threaded
Open this post in threaded view
|

Re: date format

Costas Menico-2
"smalltalk1" <[hidden email]> wrote:

>I want to create a Presenter who manages a date value in format
>'dd/mm/yyyy'.
>Otherwise I want a Date view who is in sync with this presenter.
>I do not know how can i do.
>Can someone help me?

Ok, this is based on the two minute MVP document.
I first designed a subclass of Shell and called DateShell with d1 and
d2 as instance vars.

Shell subclass: #DateShell
        instanceVariableNames: 'd1 d2'
        classVariableNames: ''
        poolDictionaries: ''
        classInstanceVariableNames: ''

I added two instance side methods.

DateShell>>createComponents
        "Create the presenters contained by the receiver"

        super createComponents.
        d1 := self add: DatePresenter new name: 'date1'.
             d2 := self add: DatePresenter new name: 'date2'.

DateShell>>clickIt
" Just increment the date by one on every click in the view"
     d1 value isNil ifTrue: [d1 value: Date today].
     d2 value isNil ifTrue: [d2 value: Date today].

     d1 value: (d1 value addDays: 1).
     d2 value: (d2 value addDays: 1).

I then designed a view called DateShell with 3 controls:

date1 as DatePresenter (Defaulkt view)

date2 as DatePresenter(Text View)

clickIt as a Pushbutton and set the command to #clickIt


Thats is all.  With one slight problem <g> maybe someone else can
check. For the DatePresenter(Text view) the date is displayed in
European format (DD/MM/YY) even though my Locale userDefault is
'a 'Locale('English (United States)')'

Costas


Reply | Threaded
Open this post in threaded view
|

Re: date format

Louis Sumberg
Costas,

> For the DatePresenter(Text view) the date is displayed in
> European format (DD/MM/YY) even though my Locale userDefault is
> 'a 'Locale('English (United States)')'

You might want to check your Windows settings -- through Control Panel /
Regional Settings.  There's a tab for
Date and it shows the default short and long format masks (which you can
change).  You can also override these in the textedit control by changing
the format aspect (you need to expand the typeconverter aspect to see this).
e.g., M/d/yy (no quotes) for the format should do it.

-- Louis


Reply | Threaded
Open this post in threaded view
|

Re: date format

Costas Menico-2
"Louis Sumberg" <[hidden email]> wrote:

>Costas,
>
>> For the DatePresenter(Text view) the date is displayed in
>> European format (DD/MM/YY) even though my Locale userDefault is
>> 'a 'Locale('English (United States)')'
>
>You might want to check your Windows settings -- through Control Panel /
>Regional Settings.  There's a tab for
>Date and it shows the default short and long format masks (which you can
>change).  You can also override these in the textedit control by changing
>the format aspect (you need to expand the typeconverter aspect to see this).
>e.g., M/d/yy (no quotes) for the format should do it.

Thanks, This works when I hardcode the format aspect ( M/d/yyyy ).
However I should not have to. The locale should be picked up
automatically by the DatePresenter since the locale is M/d/yy on my
system.  

My D4.0 system returns the following:

DateToText new format --> nil
DateToText new locale  --> a Locale('English (United States)')
Locale default dateFormat --> 'M/d/yy'

I believe there is a little problem here. I am using Dolphin 4.0.

Costas


Reply | Threaded
Open this post in threaded view
|

Re: date format

Frank Sergeant
"Costas Menico" <[hidden email]> wrote in message
news:[hidden email]...
> Thanks, This works when I hardcode the format aspect ( M/d/yyyy ).
> However I should not have to. The locale should be picked up
> automatically by the DatePresenter since the locale is M/d/yy on my
> system.

I ran into something similar when I first began with version 3.  It appeared
that even though the locale was picked up correctly (US English or
whatever), the DatePresenter.Default view (or whatever) still remembered the
locale it had been saved down with (British English or whatever).  I may
have edited the DatePresenter.Default view in the view composer and changed
whatever and then saved it, so thereafter when I dragged it to a form it
would be set right.

I'm sorry I'm so vague.  I may well be misremembering.


-- Frank
[hidden email]


Reply | Threaded
Open this post in threaded view
|

DatePresenter Text view bug

Costas Menico-2
Andy,

After a discussion with others there seems to be a minor bug in the
DatePresenter 'Text view' resource.  The default format displays the
date it in the dd/M/yy format instead of the locale format. I am using
D4.0 PL1

Costas