Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create UK dates from strings in Pharo Smalltalk?

I have some code that successfully parses strings to create dates:

date := string asDate

But this assumes US date format mm/dd/yyyy.

I know I can output a date as a string in UK format like this:

date printFormat: #(1 2 3 $/ 1 1)

So my question, how do I create a date from a UK format date string dd/mm/yyyy?

I've checked the String>>asDate method and this doesn't have any format parameter. Looking at Date class>>readFrom: (which asDate calls) it seems to have UK code in there, but how to dictate that this is what I want?

like image 774
Eric Clack Avatar asked Mar 19 '13 20:03

Eric Clack


1 Answers

Would this work for you?

Date readFrom: '04/02/2013' readStream pattern: 'dd/mm/yyyy'
like image 84
David Buck Avatar answered Nov 07 '22 18:11

David Buck