How to treat the date format uniformly in Delphi Xe, play turn Tdatetime

Source: Internet
Author: User
Tags month name

The processing of date formats is always complex, because different environment date formats are not the same. In order to process the unified processing, it is best to unify the format:

Can be in the initialization section of the program:

  Formatsettings.shortdateformat: = ' dd/mm/yyyy ';  Formatsettings.dateseparator: = '/';  For I: = 1 to    system.sysutils.formatsettings.shortmonthnames[i]: = Snames[i];

Where Snames is the global array of its own defined month name, if you display the format for example: ' dd MMM yyyy ' that ' mmm ' displays the corresponding string in this array, the definition can be:

Const  snames:array[1..12] of string = (' Jan ', ' Feb ', ' Mar ', ' Apr ', ' may ', ' June ', ' Jul ', ' April ', ' Sep ', ' Oct ', ' Nov ', ' Dec ' );

Explanation of some attributes in Tformatsettings:

Dateseparator:char Date separator, used to separate month and day
Timeseparator:char time separator, for separating hours, minutes, seconds
Shortdateformat:string the definition of the short date format in the regional settings.
Longdateformat:string the definition of the long date format in the regional settings.
Shorttimeformat:string the definition of a short time format in a locale.
Longtimeformat:string the definition of the long-time format in the regional settings.
Timeamstring:string used to represent the morning string
Timepmstring:string used to represent the afternoon string
SHORTMONTHNAMES:ARRAY[1..12] of String; An array for the abbreviated name of the month, which is the string of the MMM identity that is displayed when using FormatDateTime
LONGMONTHNAMES:ARRAY[1..12] of String; An array that is used to fully represent the name of the month, which is the mmmm identity string that is displayed when using FormatDateTime
SHORTDAYNAMES:ARRAY[1..7] of String; An array that is used to indicate the name of the day of the week, which is the DDD identity string that is displayed when using FormatDateTime
LONGDAYNAMES:ARRAY[1..7] of String; An array that is used to fully represent the name of the day, which is the string of DDD identities that are displayed when using FormatDateTime
Twodigityearcenturywindow:word = 50; The starting year when the two-bit year is used.

Transferred from: https://www.cnblogs.com/zhenfei/p/4574799.html

How to treat the date format uniformly in Delphi Xe, play turn Tdatetime

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.