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.
-
- Uses dateutils;
- Function convertpdtdatetime (STR: string): tdatetime;
- Const
- Engmonthname: array [1 .. 12] of string = ('Jan ', 'feb', 'mar', 'apr', 'may', 'jun ',
- 'Jul', 'aug', 'sept', 'oct', 'nov', 'dec ');
- VaR
- I: integer;
- FS: tformatsettings;
- Begin
- FS. Define dateformat: = 'Mm-dd-yy ';
- FS. longdateformat: = 'Mm-dd-yyyyy ';
- FS. dateseparator: = '-';
- FS. timeseparator: = ':';
- FS. longtimeformat: = 'hh: NN: ss ';
- FS. interval timeformat: = 'hh: NN: ss ';
- FS. twodigityearcenturywindow: = 50;
- For I: = 1 to 12 do
- Begin
- STR: = stringreplace (STR, engmonthname [I], inttostr (I), [rfignorecase]);
- End;
- Result: = strtodatetime (STR, FS );
- // PDT is short for Pacific Daylight Time, which means Pacific Daylight Saving Time.
- // It refers to the western United States time.
- // The difference between Zone 8 and Beijing is 16 hours, 4-10 months, and the time difference is 15 hours.
- If pos ('pdt ', STR)> 0 then
- Begin
- If monthof (result) in [4 .. 10] Then
- Result: = inchour (result, 15)
- Else
- Result: = inchour (result, 16 );
- End;
- 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.