Formating dates

View: New views
12 Messages — Rating Filter:   Alert me  

Formating dates

by Miguel Lopes-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm trying to have dates represented as YYYY/MM/DD, DD/MM/YYYY or DD/MM/YY.
Any of these would be ok as people on this side of the pond expect the
month to be the middle value.

The db field is of date type. I've tried to use both dTextBox and
dDateTextBox without success. The date is represented in the format
MM/DD/YY.

I've dabbled a bit but it dosen't seem to be an obvious solution for this.
Is there a way to accomplish this?

Txs,
Miguel
_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/a19730800911091340h18f98fc1v884ab374942b2cba@...

Re: Formating dates

by Paul McNett :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Miguel Lopes wrote:

> I'm trying to have dates represented as YYYY/MM/DD, DD/MM/YYYY or DD/MM/YY.
> Any of these would be ok as people on this side of the pond expect the
> month to be the middle value.
>
> The db field is of date type. I've tried to use both dTextBox and
> dDateTextBox without success. The date is represented in the format
> MM/DD/YY.
>
> I've dabbled a bit but it dosen't seem to be an obvious solution for this.
> Is there a way to accomplish this?

import dabo
dabo.settings.dateFormat = "%Y/%m/%d"

However, it should be defaulting to the user's localization settings for short date
format (operating on the principle that the user should be in ultimate control over
the formatting of things). If it isn't, please let us know!

Paul

_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/4AF88E14.9030001@...

Re: Formating dates

by Ed Leafe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov 9, 2009, at 3:40 PM, Miguel Lopes wrote:

> I'm trying to have dates represented as YYYY/MM/DD, DD/MM/YYYY or DD/
> MM/YY.
> Any of these would be ok as people on this side of the pond expect the
> month to be the middle value.
>
> The db field is of date type. I've tried to use both dTextBox and
> dDateTextBox without success. The date is represented in the format
> MM/DD/YY.
>
> I've dabbled a bit but it dosen't seem to be an obvious solution for  
> this.
> Is there a way to accomplish this?


        This is a module-level setting. To change it, create a file named  
'settings_override.py' in your app's home directory, and add the line:

dateFormat = "%Y/%m/%d"

... to get dates to display as "2009/11/09" in dDateTextBox. Try  
playing around with this setting until you get the display format you  
want.


-- Ed Leafe



_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/59386848-CF61-4AB6-BC28-C1E13D1F93A8@...

Re: Formating dates

by Paul McNett :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Paul McNett wrote:
> However, it should be defaulting to the user's localization settings for short date
> format (operating on the principle that the user should be in ultimate control over
> the formatting of things). If it isn't, please let us know!

I just confirmed that this is working on Windows XP. I went into 'regional and
language settings', and selected "English (United Kingdom)" and then started my app.
All the dates were messed up with the day showing before the month. :)

Paul

_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/4AF890C0.4010907@...

Re: Formating dates

by Miguel Lopes-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Nov 9, 2009 at 9:59 PM, Paul McNett <p@...> wrote:

> Paul McNett wrote:
>> However, it should be defaulting to the user's localization settings for short date
>> format (operating on the principle that the user should be in ultimate control over
>> the formatting of things). If it isn't, please let us know!
>
> I just confirmed that this is working on Windows XP. I went into 'regional and
> language settings', and selected "English (United Kingdom)" and then started my app.
> All the dates were messed up with the day showing before the month. :)
>
> Paul

I don't get the same on OSX Leopard (10.5.8)
I went to System Preferences | International | Formats
and then choosing alternative selections in the Region dropdown has no
effect on dabo's date formatting.

My dates are still messed up with the day showing after the month. :)

I've also tried overriding via the settings file with success,
including dateTimeFormat:
dateTimeFormat = "%Y/%m/%d %H:%M:%S"

Miguel
_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/a19730800911091430q78119b5cj2aa5cb7cb19cd04b@...

Re: Formating dates

by Paul McNett :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Miguel Lopes wrote:

> On Mon, Nov 9, 2009 at 9:59 PM, Paul McNett <p@...> wrote:
>> Paul McNett wrote:
>>> However, it should be defaulting to the user's localization settings for short date
>>> format (operating on the principle that the user should be in ultimate control over
>>> the formatting of things). If it isn't, please let us know!
>> I just confirmed that this is working on Windows XP. I went into 'regional and
>> language settings', and selected "English (United Kingdom)" and then started my app.
>> All the dates were messed up with the day showing before the month. :)
>>
>> Paul
>
> I don't get the same on OSX Leopard (10.5.8)
> I went to System Preferences | International | Formats
> and then choosing alternative selections in the Region dropdown has no
> effect on dabo's date formatting.
>
> My dates are still messed up with the day showing after the month. :)

Dabo just delegates this to Python, using time.strftime() with the format of "%x". So
I guess something on Mac isn't working correctly. What version of Python?


> I've also tried overriding via the settings file with success,
> including dateTimeFormat:
> dateTimeFormat = "%Y/%m/%d %H:%M:%S"

Good, I'm that that worked for you at least!

Paul
_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/4AF89C27.7020509@...

Re: Formating dates

by Paul McNett :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Paul McNett wrote:

> Miguel Lopes wrote:
>> On Mon, Nov 9, 2009 at 9:59 PM, Paul McNett <p@...> wrote:
>>> Paul McNett wrote:
>>>> However, it should be defaulting to the user's localization settings for short date
>>>> format (operating on the principle that the user should be in ultimate control over
>>>> the formatting of things). If it isn't, please let us know!
>>> I just confirmed that this is working on Windows XP. I went into 'regional and
>>> language settings', and selected "English (United Kingdom)" and then started my app.
>>> All the dates were messed up with the day showing before the month. :)
>>>
>>> Paul
>> I don't get the same on OSX Leopard (10.5.8)
>> I went to System Preferences | International | Formats
>> and then choosing alternative selections in the Region dropdown has no
>> effect on dabo's date formatting.
>>
>> My dates are still messed up with the day showing after the month. :)
>
> Dabo just delegates this to Python, using time.strftime() with the format of "%x". So
> I guess something on Mac isn't working correctly. What version of Python?

I can confirm this problem on Mac Leopard 10.5.7, using python 2.5.4:

 >>> import datetime
 >>> d = datetime.date.today()
 >>> d
datetime.date(2009, 11, 9)
 >>> import time
 >>> print time.strftime("%x", d.timetuple())
11/09/09

(should have been "2009/11/09")

Paul
_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/4AF89E49.2080405@...

Re: Formating dates

by Paul McNett :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Paul McNett wrote:

> Paul McNett wrote:
>> Miguel Lopes wrote:
>>> On Mon, Nov 9, 2009 at 9:59 PM, Paul McNett <p@...> wrote:
>>>> Paul McNett wrote:
>>>>> However, it should be defaulting to the user's localization settings for short date
>>>>> format (operating on the principle that the user should be in ultimate control over
>>>>> the formatting of things). If it isn't, please let us know!
>>>> I just confirmed that this is working on Windows XP. I went into 'regional and
>>>> language settings', and selected "English (United Kingdom)" and then started my app.
>>>> All the dates were messed up with the day showing before the month. :)
>>>>
>>>> Paul
>>> I don't get the same on OSX Leopard (10.5.8)
>>> I went to System Preferences | International | Formats
>>> and then choosing alternative selections in the Region dropdown has no
>>> effect on dabo's date formatting.
>>>
>>> My dates are still messed up with the day showing after the month. :)
>> Dabo just delegates this to Python, using time.strftime() with the format of "%x". So
>> I guess something on Mac isn't working correctly. What version of Python?
>
> I can confirm this problem on Mac Leopard 10.5.7, using python 2.5.4:
>
>  >>> import datetime
>  >>> d = datetime.date.today()
>  >>> d
> datetime.date(2009, 11, 9)
>  >>> import time
>  >>> print time.strftime("%x", d.timetuple())
> 11/09/09
>
> (should have been "2009/11/09")

Also, I can't get it to work on Ubuntu either.

Paul

_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/4AF8A121.2010703@...

Re: Formating dates

by jfabiani :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Monday 09 November 2009 03:09:21 pm Paul McNett wrote:

> Paul McNett wrote:
> > Paul McNett wrote:
> >> Miguel Lopes wrote:
> >>> On Mon, Nov 9, 2009 at 9:59 PM, Paul McNett <p@...> wrote:
> >>>> Paul McNett wrote:
> >>>>> However, it should be defaulting to the user's localization settings
> >>>>> for short date format (operating on the principle that the user
> >>>>> should be in ultimate control over the formatting of things). If it
> >>>>> isn't, please let us know!
> >>>>
> >>>> I just confirmed that this is working on Windows XP. I went into
> >>>> 'regional and language settings', and selected "English (United
> >>>> Kingdom)" and then started my app. All the dates were messed up with
> >>>> the day showing before the month. :)
> >>>>
> >>>> Paul
> >>>
> >>> I don't get the same on OSX Leopard (10.5.8)
> >>> I went to System Preferences | International | Formats
> >>> and then choosing alternative selections in the Region dropdown has no
> >>> effect on dabo's date formatting.
> >>>
> >>> My dates are still messed up with the day showing after the month. :)
> >>
> >> Dabo just delegates this to Python, using time.strftime() with the
> >> format of "%x". So I guess something on Mac isn't working correctly.
> >> What version of Python?
> >
> > I can confirm this problem on Mac Leopard 10.5.7, using python 2.5.4:
> >  >>> import datetime
> >  >>> d = datetime.date.today()
> >  >>> d
> >
> > datetime.date(2009, 11, 9)
> >
> >  >>> import time
> >  >>> print time.strftime("%x", d.timetuple())
> >
> > 11/09/09
> >
> > (should have been "2009/11/09")
>
> Also, I can't get it to work on Ubuntu either.
>
> Paul

I'm not dead sure but I think the way the above code would print depends on
the default locale.  In your case I bet it's 'en_US, UTF8'.  If I'm correct
then it is printing correctly.



Johnf


_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/200911091530.50699.jfabiani@...

Re: Formating dates

by Miguel Lopes-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Nov 9, 2009 at 10:57 PM, Paul McNett <p@...> wrote:

> Paul McNett wrote:
>> Miguel Lopes wrote:
>>> On Mon, Nov 9, 2009 at 9:59 PM, Paul McNett <p@...> wrote:
>>>> Paul McNett wrote:
>>>>> However, it should be defaulting to the user's localization settings for short date
>>>>> format (operating on the principle that the user should be in ultimate control over
>>>>> the formatting of things). If it isn't, please let us know!
>>>> I just confirmed that this is working on Windows XP. I went into 'regional and
>>>> language settings', and selected "English (United Kingdom)" and then started my app.
>>>> All the dates were messed up with the day showing before the month. :)
>>>>
>>>> Paul
>>> I don't get the same on OSX Leopard (10.5.8)
>>> I went to System Preferences | International | Formats
>>> and then choosing alternative selections in the Region dropdown has no
>>> effect on dabo's date formatting.
>>>
>>> My dates are still messed up with the day showing after the month. :)
>>
>> Dabo just delegates this to Python, using time.strftime() with the format of "%x". So
>> I guess something on Mac isn't working correctly. What version of Python?
>
> I can confirm this problem on Mac Leopard 10.5.7, using python 2.5.4:
>
>  >>> import datetime
>  >>> d = datetime.date.today()
>  >>> d
> datetime.date(2009, 11, 9)
>  >>> import time
>  >>> print time.strftime("%x", d.timetuple())
> 11/09/09
>
> (should have been "2009/11/09")
>
> Paul

Exactly the same here with Mac Leopard 10.5.8, with MacPython 2.5.4

Miguel
_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/a19730800911091531q125be8cep81f6bb05b85af0ef@...

Re: Formating dates

by Paul McNett :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

John wrote:

> On Monday 09 November 2009 03:09:21 pm Paul McNett wrote:
>> Paul McNett wrote:
>>> Paul McNett wrote:
>>>> Miguel Lopes wrote:
>>>>> On Mon, Nov 9, 2009 at 9:59 PM, Paul McNett <p@...> wrote:
>>>>>> Paul McNett wrote:
>>>>>>> However, it should be defaulting to the user's localization settings
>>>>>>> for short date format (operating on the principle that the user
>>>>>>> should be in ultimate control over the formatting of things). If it
>>>>>>> isn't, please let us know!
>>>>>> I just confirmed that this is working on Windows XP. I went into
>>>>>> 'regional and language settings', and selected "English (United
>>>>>> Kingdom)" and then started my app. All the dates were messed up with
>>>>>> the day showing before the month. :)
>>>>>>
>>>>>> Paul
>>>>> I don't get the same on OSX Leopard (10.5.8)
>>>>> I went to System Preferences | International | Formats
>>>>> and then choosing alternative selections in the Region dropdown has no
>>>>> effect on dabo's date formatting.
>>>>>
>>>>> My dates are still messed up with the day showing after the month. :)
>>>> Dabo just delegates this to Python, using time.strftime() with the
>>>> format of "%x". So I guess something on Mac isn't working correctly.
>>>> What version of Python?
>>> I can confirm this problem on Mac Leopard 10.5.7, using python 2.5.4:
>>>  >>> import datetime
>>>  >>> d = datetime.date.today()
>>>  >>> d
>>>
>>> datetime.date(2009, 11, 9)
>>>
>>>  >>> import time
>>>  >>> print time.strftime("%x", d.timetuple())
>>>
>>> 11/09/09
>>>
>>> (should have been "2009/11/09")
>> Also, I can't get it to work on Ubuntu either.
>>
>> Paul
>
> I'm not dead sure but I think the way the above code would print depends on
> the default locale.  In your case I bet it's 'en_US, UTF8'.  If I'm correct
> then it is printing correctly.

Bingo, John. It prints the date format for the current language setting, using the
$LANG environmental variable on Mac and Linux.

After changing the region in system preferences, you need to start a new terminal so
that $LANG reflects the new value.

So Miguel, go into System Preferences|International|Formats and choose the region
"United Kingdom". Then start a new terminal and run your test. I get the UK format on
my Mac when I do this.

Paul
_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/4AF8AD18.8040003@...

Re: Formating dates

by Miguel Lopes-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Nov 10, 2009 at 12:00 AM, Paul McNett <p@...> wrote:

> John wrote:
>> On Monday 09 November 2009 03:09:21 pm Paul McNett wrote:
>>> Paul McNett wrote:
>>>> Paul McNett wrote:
>>>>> Miguel Lopes wrote:
>>>>>> On Mon, Nov 9, 2009 at 9:59 PM, Paul McNett <p@...> wrote:
>>>>>>> Paul McNett wrote:
>>>>>>>> However, it should be defaulting to the user's localization settings
>>>>>>>> for short date format (operating on the principle that the user
>>>>>>>> should be in ultimate control over the formatting of things). If it
>>>>>>>> isn't, please let us know!
>>>>>>> I just confirmed that this is working on Windows XP. I went into
>>>>>>> 'regional and language settings', and selected "English (United
>>>>>>> Kingdom)" and then started my app. All the dates were messed up with
>>>>>>> the day showing before the month. :)
>>>>>>>
>>>>>>> Paul
>>>>>> I don't get the same on OSX Leopard (10.5.8)
>>>>>> I went to System Preferences | International | Formats
>>>>>> and then choosing alternative selections in the Region dropdown has no
>>>>>> effect on dabo's date formatting.
>>>>>>
>>>>>> My dates are still messed up with the day showing after the month. :)
>>>>> Dabo just delegates this to Python, using time.strftime() with the
>>>>> format of "%x". So I guess something on Mac isn't working correctly.
>>>>> What version of Python?
>>>> I can confirm this problem on Mac Leopard 10.5.7, using python 2.5.4:
>>>>  >>> import datetime
>>>>  >>> d = datetime.date.today()
>>>>  >>> d
>>>>
>>>> datetime.date(2009, 11, 9)
>>>>
>>>>  >>> import time
>>>>  >>> print time.strftime("%x", d.timetuple())
>>>>
>>>> 11/09/09
>>>>
>>>> (should have been "2009/11/09")
>>> Also, I can't get it to work on Ubuntu either.
>>>
>>> Paul
>>
>> I'm not dead sure but I think the way the above code would print depends on
>> the default locale.  In your case I bet it's 'en_US, UTF8'.  If I'm correct
>> then it is printing correctly.
>
> Bingo, John. It prints the date format for the current language setting, using the
> $LANG environmental variable on Mac and Linux.
>
> After changing the region in system preferences, you need to start a new terminal so
> that $LANG reflects the new value.
>
> So Miguel, go into System Preferences|International|Formats and choose the region
> "United Kingdom". Then start a new terminal and run your test. I get the UK format on
> my Mac when I do this.
>
> Paul
> _______________________________________________
> Post Messages to: Dabo-users@...
> Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
> Searchable Archives: http://leafe.com/archives/search/dabo-users
> This message: http://leafe.com/archives/byMID/4AF8AD18.8040003@...
>

Thanks for the pointer. It's ok here too.
Miguel
_______________________________________________
Post Messages to: Dabo-users@...
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/a19730800911091636n74f15240ya379bf980a32a4e4@...