Dates..
Just how many ways are there to fool with dates?
Don't answer that - its a big number.
Nowadays - with faster processors and timestamps needing more precision, I've gone to a line of RPGLE user source contained in a function called 'Timestamp accurately'
Here's the USRSRC - and, yes, its using a WRK context
** provide an updated timestamp
D Zztimestamp S z ; timestamp
** /\/\/
C** /\/\/
** provide an updated timestamp
C** user source to generate accurate timestamp
C Time Zztimestamp
C MOVE zztimestamp wuagts ; into WRK context
C**
** provide an updated timestamp
C** /\/\/
and that USRSRC is embedded in this INTFUN - using the WRK variable nails the field name in place. I could have used #I and #O direct to the the usrsrc, but didn't - can't remember why not now - probably something to do with the function it first went into.
> Timestamp accurately
.--
. /** intfun start
. ** Jan 2004 - included usrsrc to run %timestamp
. ** fix the field name by using WRK for the code line
. WRK.Timestamp = LCL.Timestamp
. time opcode to par - #Utilities * <<----- this is the USRSRC
. PAR.Timestamp = WRK.Timestamp
. /** intfun end
'--
I see I have quite a range of functions for decomposing timestamps, comparing them, and so on.
equally, I now have a single function for date format conversion - 'all known date formats' are parameters, and when it is called with just 1 value, it returns all other fields in converted form.
so something like this
Clear all date fields
Get current timestamp
extract date from timestamp
convert date to 'all known formats'
place required date (and time?) wherever its needed
Richard Wilson