Delphi: 1. PDT time to Beijing time; 2. Conditional compilation

Source: Internet
Author: User
1. PDT time to Beijing Time
We made a little thing, the time is PDT, and the month is also in English. I wrote a small function and copied it directly if necessary :)
There are better implementation methods. Please reply.
  1. Uses dateutils;
  2. Function convertpdtdatetime (STR: string): tdatetime;
  3. Const
  4. Engmonthname: array [1 .. 12] of string = ('Jan ', 'feb', 'mar', 'apr', 'may', 'jun ',
  5. 'Jul', 'aug', 'sept', 'oct', 'nov', 'dec ');
  6. VaR
  7. I: integer;
  8. FS: tformatsettings;
  9. Begin
  10. FS. Define dateformat: = 'Mm-dd-yy ';
  11. FS. longdateformat: = 'Mm-dd-yyyyy ';
  12. FS. dateseparator: = '-';
  13. FS. timeseparator: = ':';
  14. FS. longtimeformat: = 'hh: NN: ss ';
  15. FS. interval timeformat: = 'hh: NN: ss ';
  16. FS. twodigityearcenturywindow: = 50;
  17. For I: = 1 to 12 do
  18. Begin
  19. STR: = stringreplace (STR, engmonthname [I], inttostr (I), [rfignorecase]);
  20. End;
  21. Result: = strtodatetime (STR, FS );
  22. // PDT is short for Pacific Daylight Time, which means Pacific Daylight Saving Time.
  23. // It refers to the western United States time.
  24. // The difference between Zone 8 and Beijing is 16 hours, 4-10 months, and the time difference is 15 hours.
  25. If pos ('pdt ', STR)> 0 then
  26. Begin
  27. If monthof (result) in [4 .. 10] Then
  28. Result: = inchour (result, 15)
  29. Else
  30. Result: = inchour (result, 16 );
  31. End;
  32. End;

 
 

Call method: convertpdtdatetime ('occt-21-08 12:01:10 PDT ')

2. Conditional compilation:
If you want to use the command line dcc32.exe to compile the project, please CD it to the directory where DPR is located, otherwise the condition variable may not take effect (at least I {$ I XXX. inc} entered is invalid.

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.