SetFDateTime() is missing
Posted: Sun May 26, 2019 4:13 pm
Guys,
without changing the SetFDateTime() sources it´s not possible to set the timeStamp of a file to "00:00:00". When you run this sample in VO the Filedate is as expected the current date - 2 , but the Filetime is set to the current system time.
That´s what VO does if a "00:00:00" timestamp is passed:
- To be compatible with VO i created two overloads.
- Another option is to use a single func with an optional param instead. If this param is set to TRUE a "00:00:00" timestamp is not changed to the current system time.
What do you think is the best solution ?
regards
Karl-Heinz
without changing the SetFDateTime() sources it´s not possible to set the timeStamp of a file to "00:00:00". When you run this sample in VO the Filedate is as expected the current date - 2 , but the Filetime is set to the current system time.
Code: Select all
SetFDateTime ( "C:xyzxyz.txt" , Today() - 2 , "00:00:00" )
Code: Select all
IF Secs ( cTimeStamp ) == 0
cTimeStamp := Time()
ENDIF
- To be compatible with VO i created two overloads.
Code: Select all
FUNCTION SetFDateTime ( cFile AS STRING , dStamp AS DATE , cTimeStamp AS STRING ) AS LOGIC
RETURN SetFDateTime ( cFile , dStamp , cTimeStamp , FALSE )
FUNCTION SetFDateTime ( cFile AS STRING , dStamp AS DATE , cTimeStamp AS STRING , lAllowZeroTimeStamp AS LOGIC ) AS LOGIC
LOCAL lOk AS LOGIC
TRY
lOk := TRUE
// VO behaviour if a NULL_DATE is passed
IF dStamp == NULL_DATE
dStamp := Today()
ENDIF
IF ! lAllowZeroTimeStamp
// VO behaviour if the TimeStamp "00:00:00" is passed
IF Secs ( cTimeStamp ) == 0
cTimeStamp := Time()
ENDIF
ENDIF
VAR ts := TimeSpan.Parse( cTimeStamp )
File.SetLastWriteTime( cFile ,;
DateTime { (INT) Year ( dStamp ) , (INT) Month ( dStamp ) , (INT) Day( dStamp ) ,;
ts:hours , ts:minutes , ts:Seconds } )
CATCH
lOk := FALSE
END TRY
RETURN lOk
Code: Select all
FUNCTION SetFDateTime ( cFile AS STRING , dStamp AS DATE , cTimeStamp AS STRING , lAllowZeroTimeStamp := FALSE AS LOGIC ) AS LOGIC
regards
Karl-Heinz