Easiest way to present Dates

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

Easiest way to present Dates

keith1y
I have been looking for the easiest way to get a date to display with
the desired format.

By adding

BlockContext-write: anObject description: aDescription

    ^ self value: anObject

The following becomes possible:

    ^ MADateDescription new
        selectorAccessor: #orderDate;
        beWithinYears: 2;
        stringWriter: [ :i | i mmddyyyy ];
        label: 'Order Date';
        beReadonly;
        beSearchable;
        yourself
       
Is there a better way?
Is this worth adding to the mainstream?

Keith


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Easiest way to present Dates

Lukas Renggli-2
> BlockContext-write: anObject description: aDescription

>
>    ^ self value: anObject
>
> The following becomes possible:
>
>    ^ MADateDescription new
>        selectorAccessor: #orderDate;
>        beWithinYears: 2;
>        stringWriter: [ :i | i mmddyyyy ];
>        label: 'Order Date';
>        beReadonly;
>        beSearchable;
>        yourself
>
> Is there a better way?
> Is this worth adding to the mainstream?
This is a nice trick. I am not a big fan of unnecessarily adding block-
contexts to my model. As soon as you want to make your meta-model  
persistent or editable you run into troubles ...

What I usually did for my applications is to subclass the standard  
string writer with my configuration for dates and times to generate  
the desired output.

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch



_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki

smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Easiest way to present Dates

keith1y

>
> This is a nice trick. I am not a big fan of unnecessarily adding
> block-contexts to my model. As soon as you want to make your
> meta-model persistent or editable you run into troubles ...
>
> What I usually did for my applications is to subclass the standard
> string writer with my configuration for dates and times to generate
> the desired output.
>
> Cheers,
> Lukas
Thanks Lukas, I guess I was just being lazy... I conceded in the end.

Keith

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki