![]() TwoDigitYearCenturyWindow := 75 // This means 49 is treated as 1949 LongDateFormat := 'dddd dd of mmmm of yyyy' ShowMessage(' hhampm = '+ FormatDateTime('hhampm', myDate)) ![]() ShowMessage(' dddddd = '+ FormatDateTime('dddddd', myDate)) ShowMessage(' ddddd = '+ FormatDateTime('ddddd', myDate)) ShowMessage(' dddd = '+ FormatDateTime('dddd', myDate)) ShowMessage(' ddd = '+ FormatDateTime('ddd', myDate)) ShowMessage(' mmmm = '+ FormatDateTime('mmmm', myDate)) ShowMessage(' mmm = '+ FormatDateTime('mmm', myDate)) Use the DateSeparator and TimeSeparator valuesįormatDateTime('dd/mm/yy hh:nn:ss', myDate)) So the year is in the next century => 2049 Compare with the last 2 digits of 1958 => Less Subtract TwoDigitYearCenturyWindow => 1958 Current year => 2008 (at time of writing) Note that 49 is treated as 2049 as follows : ShowMessage(' c = '+ FormatDateTime('c', myDate)) Įxample code : Showing the effect of local date format settings ShowMessage(' tt = '+ FormatDateTime('tt', myDate)) ShowMessage(' t = '+ FormatDateTime('t', myDate)) ShowMessage('hh:nn:ss.zzz = '+ FormatDateTime('hh:nn:ss.zzz', myDate)) Time only - numeric values with leading zeroes ShowMessage(' h:n:s.z = '+ FormatDateTime('h:n:s.z', myDate)) Time only - numeric values with no leading zeroes Use the ShortDateFormat + LongTimeFormat settingsĭddd d of mmmm yyyy = Monday 5 of June 2000Įxample code : Showing all of the time field formatting data types Use short names for the day, month, and add freeform text ('of')įormatDateTime('ddd d of mmm yyyy', myDate)) įormatDateTime('dddd d of mmmm yyyy', myDate)) Date only - numeric values with leading zeroes Date only - numeric values with no leading zeroes (except year) Set up our TDateTime variable with a full date and time : Sets the century threshold for 2 digit year string conversionsĮxample code : Showing all of the date field formatting data types The character used to separate display time fields Short version of the time to string formatĬonverts a date+time string into a TDateTime valueĭetermines AM value in DateTimeToString procedureĭetermines PM value in DateTimeToString procedure Long version of the time to string formatĬompact version of the date to string formatĪn array of days of the month names, starting 1 = Jan Long version of the date to string formatĪn array of days of the week names, starting 1 = SundayĪn array of days of the month names, starting 1 = January The character used to separate display date fieldsĬonverts TDateTime date and time values to a string It takes a local copy of global formatting variables that make the routine thread safe. You furnish the FormatSettings record before invoking the call. Version 2 of this function is for use within threads. In addition to this formatting, various of the above options are affected by the following variables, withe their default values : Important : if you want to see characters such as dd in the formatted output, placing them in " marks will stop them being interpreted as date or time elements. The following (non-Asian) formatting character strings can be used in the Formatting string: This formatting is best explained by the example code. The Formatting string can comprise a mix of ordinary characters (that are passed unchanged to the result string), and data formatting characters. Formatting is defined by the Formatting string. The FormatDateTime function provides rich formatting of a TDateTime value DateTime into a string. Rich formatting of a TDateTime variable into a stringĬonst Formatting : string DateTime : TDateTimeĬonst Formatting : string DateTime : TDateTime const FormatSettings : TFormatSettings Smart Pascal : FormatDateTime command Smart Pascal
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |