Your question, your audience. Choose who sees your identity—and your question—with question security.
H Debug( *yes )
H*Debug( *no )
H Nomain
H*DFTACTGRP(*NO)
d CHAR255_ s 255
d TIMESTAMP_ s 26
d VSTRING_ ds inz
d l2pstring +2 like( CHAR255_ ) overlay( VSTRING_ )
d l2len 5i 0 overlay( l2pstring : 1 )
d l2string 255 overlay( l2pstring : 3 )
d l4pstring +4 like( CHAR255_ ) overlay( VSTRING_ )
d l4len 10i 0 overlay( l4pstring : 1 )
d l4string 255 overlay( l4pstring : 5 )
d stringz 1 overlay( VSTRING_ )
d FEEDBACK_ ds inz
d MsgSev 5i 0
d MsgNbr 5i 0
d Flags 1a
d Case like( Flags ) overlay( Flags )
d Severity like( Flags ) overlay( Flags )
d Control like( Flags ) overlay( Flags )
d Facility_ID 1 dim( 3 )
d I_S_Info 10u 0
d CeeCvtTimestringToSecs...
d pr 8f extproc( 'CeeCvtTimestringToSecs' )
d peTimestring 26 const
d pePicture 26 const
d CeeCvtSecsToTimestamp...
d pr extproc( 'CeeCvtSecsToTimestamp' )
d like( TIMESTAMP_ )
d peSecs 8f value
P*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
p CeeCvtTimestringToSecs...
p b export
d CeeCvtTimestringToSecs...
d pi 8f
d peTimestring 26 const
d pePicture 26 const
d CEESECS pr extproc( 'CEESECS' )
d opdesc
d TimeStamp like( VSTRING_ ) OPTIONS( *VARSIZE )
d const
d Picture like( VSTRING_ ) OPTIONS( *VARSIZE )
d const
d seconds 8f
d feedbackCode like( FEEDBACK_ ) options( *OMIT )
d theNbrOfSecs s 8f
d fc s like( FEEDBACK_ )
/free
callP CEESECS ( peTimestring :
pePicture :
theNbrOfSecs :
fc );
return ( theNbrOfSecs );
/end-free
p e
P*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
p CeeCvtSecsToTimestamp...
p b export
d CeeCvtSecsToTimestamp...
d pi like( TIMESTAMP_ )
d peSecs 8f value
d CEEDATM pr extproc( 'CEEDATM' )
d opdesc
d Seconds 8f
d Picture like( VSTRING_ ) OPTIONS( *VARSIZE )
d const
d Timestamp like( TIMESTAMP_ )
d feedbackCode like( FEEDBACK_ ) options( *OMIT )
d wwTimestamp s like( TIMESTAMP_ )
d fc s like( FEEDBACK_ )
/free
callP CEEDATM ( peSecs :
'YYYY-MM-DD-HH.MI.SS' :
wwTimestamp :
fc );
return ( wwTimestamp );
/end-free
p e
The module has two exported procs, CeeCvtTimestringToSecs() and CeeCvtSecsToTimestamp(). The CeeCvtTimestringToSecs() proc calls the CEESECS() ILE CEE* API to convert some date/time string into a value representing the number of seconds since 00:00:00 14 October 1582. (You can look up why that date is meaningful if you wish.) The CeeCvtSecsToTimestamp() proc calls CEEDATM() to convert the number of seconds into an ISO timestamp.pgm
dcl &timeString *char 26 value( '2016-10-27-15:52:05' )
dcl &picture *char 26 value( 'YYYY-MM-DD-HH:MI:SS' )
dcl &timeStamp *char 26 value( ' ' )
dcl &secs *char 8 value( x'0000000000000000' )
callprc 'CeeCvtTimestringToSecs' ( &timeString +
&picture ) +
rtnVal( &secs )
callprc 'CeeCvtSecsToTimestamp' ( &secs ) +
rtnVal( &timeStamp )
dmpclpgm
return
endpgm
Compile the two modules. Then use CRTPGM to bind them together. The RPGLE module could even be part of a larger date-handling service program.Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.