Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2003-03

FormatDateTime()

8 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luis Mineiro
to Michael Van Canneyt: You should set the 'DateSeparator' char (in sysutils) to '/' instead of the defalt '-'.…

Using libc's nl_langinfo() function should do the job. Don't know any Pascal'ish function(s) for this.

Things like THOUSEP (thousand separator), CRNCYSTR (currency symbol), etc can be queried this way for the current locale.

Cheers.

Michael Van Canneyt wrote 34 lines
On 26 Mar 2003, Tony Maro wrote: > Can anyone help me figure out why: > FormatDateTime('MM/DD/YYYY', ThisDate) > always results in something looking like: > MM-DD-YYYY > > It replaces my chosen slash with a dash. > > That's fine for you foreigner's, but us warmongering Americans like > slashes in our dates. ;-) > > I know it's an FPC and not a Lazarus question, just wondering if someone > knows an easy workaround. So far I'm having to manual separate out a > date and reconstruct it myself to get what I want. You should set the 'DateSeparator' char (in sysutils) to '/' instead of the defalt '-'. Then all date routines will use /... If someone knows how to obtain these values from Linux, let me know, and I'll have them initialized correctly from the OS environment. Same for timeseparator shorttimeformat longtimeformat Decimalseparator thousandseparator Currencydecimals Currencystring Michael. _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Luis Mineiro () ZBit Software, Lda. (http://www.zbit.pt)

Reply by email

Tony Maro

Can anyone help me figure out why:
FormatDateTime('MM/DD/YYYY', ThisDate)
always results in something looking like:
MM-DD-YYYY

It replaces my chosen slash with a dash.

That's fine for you foreigner's, but us warmongering Americans like slashes in our dates. ;-)

I know it's an FPC and not a Lazarus question, just wondering if someone knows an easy workaround. So far I'm having to manual separate out a date and reconstruct it myself to get what I want.

Tony Maro http://tony.maro.net/ Check out my software "CheckBook Tracker" A GPL (free) replacement for Microsoft Money!

Reply by email

Michael Van Canneyt
to Tony Maro
Tony Maro wrote 13 lines
Can anyone help me figure out why: FormatDateTime('MM/DD/YYYY', ThisDate) always results in something looking like: MM-DD-YYYY It replaces my chosen slash with a dash. That's fine for you foreigner's, but us warmongering Americans like slashes in our dates. ;-) I know it's an FPC and not a Lazarus question, just wondering if someone knows an easy workaround. So far I'm having to manual separate out a date and reconstruct it myself to get what I want.

You should set the 'DateSeparator' char (in sysutils) to '/' instead of the defalt '-'. Then all date routines will use /...

If someone knows how to obtain these values from Linux, let me know, and I'll have them initialized correctly from the OS environment. Same for timeseparator
shorttimeformat
longtimeformat
Decimalseparator
thousandseparator
Currencydecimals
Currencystring

Michael.

Reply by email

Michael Van Canneyt
to Luis Mineiro: Using libc's nl_langinfo() function should do the job. Don't know any Pascal'ish…
Luis Mineiro wrote 5 lines
Using libc's nl_langinfo() function should do the job. Don't know any Pascal'ish function(s) for this. Things like THOUSEP (thousand separator), CRNCYSTR (currency symbol), etc can be queried this way for the current locale.

Thank you, I'll have a look at their implementation.

I'll need to create a pascal version, because sysutils should remain independent from libc.

OTOH, I could make a separate unit which uses libc, and sets the options in sysutils using defaults obtained from libc. It's then up to the user to decide which one he uses.

Michael.

Reply by email

Luis Mineiro
to Tony Maro: Can anyone help me figure out why: FormatDateTime('MM/DD/YYYY', ThisDate) always results…

Hi,

<snip>
Program foo;
Uses
        SysUtils;
Var
        S: String;
Begin
        DateSeparator := '/';
        S := FormatDateTime('MM/DD/YYYY', Date);
        WriteLn(S);
End.
</snip>

toaster]$ fpc foo.pp
Free Pascal Compiler version 1.1 [2003/03/26] for i386 Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Linux for i386
Compiling foo.pp
Linking foo
10 Lines compiled, 0.1 sec
toaster]$ ./foo
03/27/2003

DateSeparator (declared in SysUtils), like in Delphi/Kylix, is a variable for locale specific functions that use dates.

There are others: DecimalSeparator, etc.

Cheers.

Tony Maro wrote 13 lines
Can anyone help me figure out why: FormatDateTime('MM/DD/YYYY', ThisDate) always results in something looking like: MM-DD-YYYY It replaces my chosen slash with a dash. That's fine for you foreigner's, but us warmongering Americans like slashes in our dates. ;-) I know it's an FPC and not a Lazarus question, just wondering if someone knows an easy workaround. So far I'm having to manual separate out a date and reconstruct it myself to get what I want.
Luis Mineiro () ZBit Software, Lda. (http://www.zbit.pt)

Reply by email

Unknown author
No it does not work even if you set DateSeparator := '/' you can try to use
FormatDateTime('m"/"d"/"y',Now) to get the desired result.

Regards,

Yoyong

Internet Mail Message
Received from host:
svcr-216-37-230-2.dsl.svcr.epix.net
[216.37.230.2]

From: Michael Van Canneyt on 03/27/2003 08:23 AM
GMT

Michael Van Canneyt To: Lazarus List
Cc: (bcc: Yoyong Hernan-ET/PGI)
Subject: Re: [lazarus] FormatDateTime()

03/27/2003 04:23 PM
Please respond to

Tony Maro wrote 13 lines
Can anyone help me figure out why: FormatDateTime('MM/DD/YYYY', ThisDate) always results in something looking like: MM-DD-YYYY It replaces my chosen slash with a dash. That's fine for you foreigner's, but us warmongering Americans like slashes in our dates. ;-) I know it's an FPC and not a Lazarus question, just wondering if someone knows an easy workaround. So far I'm having to manual separate out a date and reconstruct it myself to get what I want.

You should set the 'DateSeparator' char (in sysutils) to '/' instead of the defalt '-'. Then all date routines will use /...

If someone knows how to obtain these values from Linux, let me know, and I'll have them initialized correctly from the OS environment. Same for timeseparator
shorttimeformat
longtimeformat
Decimalseparator
thousandseparator
Currencydecimals
Currencystring

Michael.

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Unknown author
Try using FormatDateTime('m"/"d"/"y',Now);

Yoyong

From: Tony Maro on 03/27/2003 03:28 AM GMT

Tony Maro To: Lazarus List
Cc: (bcc: Yoyong Hernan-ET/PGI)
Subject: [lazarus] FormatDateTime()

03/27/2003 11:28 AM
Please respond to

Can anyone help me figure out why:
FormatDateTime('MM/DD/YYYY', ThisDate)
always results in something looking like:
MM-DD-YYYY

It replaces my chosen slash with a dash.

That's fine for you foreigner's, but us warmongering Americans like slashes in our dates. ;-)

I know it's an FPC and not a Lazarus question, just wondering if someone knows an easy workaround. So far I'm having to manual separate out a date and reconstruct it myself to get what I want.

Tony Maro http://tony.maro.net/ Check out my software "CheckBook Tracker" A GPL (free) replacement for Microsoft Money! _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Unknown author

I tried that one is a Lazarus project but I does not work. The scope of DateSeparator is global, right? So I changed it in FormCreate to DateSeparator : = '/' but it does not work.

Regards,

Yoyong

Internet Mail Message
Received from host:
svcr-216-37-230-2.dsl.svcr.epix.net
[216.37.230.2]

From: Luis Mineiro on 03/27/2003 09:46 AM GMT

Luis Mineiro To:
Cc: (bcc: Yoyong Hernan-ET/PGI)
Subject: Re: [lazarus] FormatDateTime()

03/27/2003 05:46 PM
Please respond to

Hi,

<snip>
Program foo;
Uses
        SysUtils;
Var
        S: String;
Begin
        DateSeparator := '/';
        S := FormatDateTime('MM/DD/YYYY', Date);
        WriteLn(S);
End.
</snip>

toaster]$ fpc foo.pp
Free Pascal Compiler version 1.1 [2003/03/26] for i386 Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Linux for i386
Compiling foo.pp
Linking foo
10 Lines compiled, 0.1 sec
toaster]$ ./foo
03/27/2003

DateSeparator (declared in SysUtils), like in Delphi/Kylix, is a variable for locale specific functions that use dates.

There are others: DecimalSeparator, etc.

Cheers.

Tony Maro wrote 13 lines
Can anyone help me figure out why: FormatDateTime('MM/DD/YYYY', ThisDate) always results in something looking like: MM-DD-YYYY It replaces my chosen slash with a dash. That's fine for you foreigner's, but us warmongering Americans like slashes in our dates. ;-) I know it's an FPC and not a Lazarus question, just wondering if someone knows an easy workaround. So far I'm having to manual separate out a date and reconstruct it myself to get what I want.
Luis Mineiro () ZBit Software, Lda. (http://www.zbit.pt) _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email