Mega Code Archive
Longdateformat - long version of the date to string format
var LongDateFormat : string;
Description
The LongDateFormat variable provides the long (extended) formatting used for certain date to string conversions.
It is used by the DateTimeToString routine when the 'dddddd' formatting is used. The following formatting character strings can be used in the LongDateFormat string:
y = Year last 2 digits
yy = Year last 2 digits
yyyy = Year as 4 digits
m = Month number no-leading 0
mm = Month number as 2 digits
mmm = Month using ShortDayNames (Jan)
mmmm = Month using LongDayNames (January)
d = Day number no-leading 0
dd = Day number as 2 digits
ddd = Day using ShortDayNames (Sun)
dddd = Day using LongDayNames (Sunday)
Notes
The default value is set from LOCALE_SLONGDATE
Related commands
DateTimeToStr Converts TDateTime date and time values to a string
DateTimeToString Rich formatting of a TDateTime variable into a string
DateToStr Converts a TDateTime date value to a string
FormatDateTime Rich formatting of a TDateTime variable into a string
ShortDateFormat Compact version of the date to string format
Example code : Illustrating customised LongDateFormat setting
var
myDate : TDateTime;
formattedDate : string;
begin
myDate := StrToDate('29/02/2000');
// Display using the default LongDateFormat
DateTimeToString(formattedDate, 'dddddd', myDate);
ShowMessage('29/02/2000 using default = '+formattedDate);
// Change the display formatting
LongDateFormat := 'dddd dd of mmmm yyyy';
DateTimeToString(formattedDate, 'dddddd', myDate);
ShowMessage('29/02/2000 using override = '+formattedDate);
end;
Show full unit code
29/02/2000 using default = 29 February 2000
29/02/2000 using override = Tuesday 29 of February 2000