Hi Tim,

Great that you found this out.

You can also use the 'by-example formatter/parser'.

ZTimestampFormat verbose 
        timezone: (ZTimezone id: 'America/Halifax');
        format: ZTimestamp now.

  => 'Saturday, 15-July-2017 04:04:12 AM (-03:00)'      

(ZTimestampFormat fromString: 'Sat, 03 February 2001 04:05:06 PM')
        timezone: (ZTimezone id: 'America/Halifax');
        format: ZTimestamp now. 
        
  => 'Sat, 15 July 2017 04:04:18 AM'

The idea is that you create a format instance once and keep using it.

Sven

PS: Check the class comment!

> On 15 Jul 2017, at 01:57, Tim Mackinnon <tim@testit.works> wrote:
> 
> Classic - the moment you write something, it suddenly dawns on you… its the 
> other way around.
> 
> (ZTimezone id: 'America/Halifax’) gmtToLocal: ZTimestamp now…
> 
> Tim
> 
>> On 15 Jul 2017, at 00:34, Tim Mackinnon <tim@testit.works> wrote:
>> 
>> Thanks for chipping in - but its the other way around that I’m after.
>> 
>> I am looking at ZTimestamp now -but again I don’t quite get it?
>> 
>> ZTimestamp now gives me a timestamp in UTC (great) but how do I format it to 
>> show it in say Canadian time?
>> 
>> I thought it would be something like:
>> 
>> ZTimestamp now printOn: stream timezone: (ZTimezone id: 'America/Halifax’) 
>> but it doesn’t seem to be that?
>> 
>> I must be missing something.
>> 
>> Tim
>> 
>>> On 14 Jul 2017, at 23:28, Norbert Hartl <norb...@hartl.name> wrote:
>>> 
>>> Have a look at #asLocal
>>> 
>>> Norbert
>>> 
>>>> Am 14.07.2017 um 23:04 schrieb Tim Mackinnon <tim@testit.works>:
>>>> 
>>>> Hi - I’m really confused about DateAndTime support in Pharo?
>>>> 
>>>> If I have a server app running in the EU, and a user makes a request from 
>>>> Canada, and I want to format the time they see to be in their timezone - 
>>>> how do I do that with the classes in Pharo?
>>>> 
>>>> I can ask for a DataAndTime nowUTC, and if I know the user is in en-CA, I 
>>>> can create a Locale for them - but then how do I get the correct time 
>>>> offset, or how to I format that UTC date in their locale?
>>>> 
>>>> Tim
>>> 
>> 
>> 
> 
> 


Reply via email to