|
|
| Line 1: |
Line 1: |
| Data types of date, time, and timestamps are external to RPGLE and thus are somewhat special to handle. Support for date/time handling has to be explicitly enabled by <code>CVTOPT(*DATETIME)</code> in the <code>H</code> specs.
| | #REDIRECT [[Using timestamps in RPG]] |
| | |
| In turn, (DDS) defined database fields are '''not''' correctly imported as the appropriate data type by just referencing the file. My approach to handle timestamps therefore consists of multiple variables:
| |
| | |
| ;CHANGED
| |
| :is a timestamp field in the database (physical file).<ref>RPG imports that as anything but a timestamp declared in the <code>D</code> statements.</ref>
| |
| ;STAMP$
| |
| :is a 19 character field in the DSPF, for containing the pretty printed timestamp.
| |
| ;STAMP
| |
| :is the RPGLE defined timestamp (<code>Z</code>) field. The <code>TIME</code> operator writes to this variable.
| |
| | |
| == Code ==
| |
| * Variable definition (in addition to autogenerated ones from referenced files).
| |
| D* For saving/handling timetamp data.
| |
| DSTAMP S Z
| |
| | |
| * Current time → Database
| |
| C* Get current timestamp.
| |
| C TIME STAMP
| |
| C MOVEL STAMP CHANGED
| |
| | |
| * Database → Pretty print DSPF field
| |
| C*
| |
| C* Get timestamp, and produce nice version thereof.
| |
| C MOVEL CHANGED STAMP$
| |
| C '.':':' XLATE STAMP$ STAMP$
| |
| C '-':' ' XLATE STAMP$:11 STAMP$
| |
| | |
| == Footnotes ==
| |
| <references />
| |
| | |
| [[Category: Programming]]
| |