Recent

Author Topic: How to display the date as MM-DD-YYYY in TDateEdit ?  (Read 11745 times)

Anonymous

  • Guest
How to display the date as MM-DD-YYYY in TDateEdit ?
« on: September 24, 2005, 05:24:59 am »
TDateEdit control. How to make the control to display the date as  MM-DD-YYYY the default is DD-MM-YYYY not all countries are using this format. TIA

matthijs

  • Hero Member
  • *****
  • Posts: 537
RE: How to display the date as MM-DD-YYYY in TDateEdit ?
« Reply #1 on: September 26, 2005, 08:39:09 am »
You don't set the display format on a control basis. Display formats for dates should be set application wide, although this is very bad practice. You could change the display format for a date by:
Code: [Select]

  ShortDateFormat := 'mm-dd-yyyy';

And personally I think the American date notation is the most illogical way to do it. :D
What's in a sig? Would my posting look less if it didnot have a sig? (Free after William S.) :)

:( Why cannot I upload my own Avatar? :(

Anonymous

  • Guest
Re: RE: How to display the date as MM-DD-YYYY in TDateEdit
« Reply #2 on: September 26, 2005, 05:08:18 pm »
Quote from: "matthijs"
You don't set the display format on a control basis. Display formats for dates should be set application wide, although this is very bad practice. You could change the display format for a date by:
Code: [Select]

  ShortDateFormat := 'mm-dd-yyyy';


Thanks Matthijas, it works!  I put in  FormCreate
Code: [Select]

  if  libc.getenv('LC_TIME') = 'en_US'  then
      ShortDateFormat := 'mm-dd-yyyy';          


Why setting the format  application wide is bad practice?  Are there any other code depend on specific date format internally?

How about the numeric display of  monetary values. Is there any global setting for
$ 123,123.12  like in US  and other countries have  123.123,12  ?  
 
LC_MONETARY=en_US


Quote
And personally I think the American date notation is the most illogical way to do it. :D


I absolutely agree, the date notation as well as many other things are wacko .

matthijs

  • Hero Member
  • *****
  • Posts: 537
Re: RE: How to display the date as MM-DD-YYYY in TDateEdit
« Reply #3 on: September 26, 2005, 10:19:08 pm »
Quote from: "Anonymous"

Why setting the format  application wide is bad practice?  Are there any other code depend on specific date format internally?

Because you might confuse your user. Suppose he is used to the dateformat dd-mm-yyyy and you change it in your app to mm-dd-yyyy, then when he sees a date like 12-05-2005 he might expect it to be the 12th of may, but it is the 5th of december! So I think it is bad practice to change these settings in the GUI. What you do internally is completely up to you of course.
What's in a sig? Would my posting look less if it didnot have a sig? (Free after William S.) :)

:( Why cannot I upload my own Avatar? :(

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2519
RE: Re: RE: How to display the date as MM-DD-YYYY in TDate
« Reply #4 on: September 27, 2005, 11:43:02 am »
BTW, in stead of using libc.getenv, it is more portable (and less libc dependent) to use
GetEnvironmentVariable declared in SysUtils
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

 

TinyPortal © 2005-2018