Page 1 of 1
SetFileDate() and GetFileDate()
Posted: Mon Feb 12, 2024 9:58 pm
by User_Russian
If you look at the file properties in Explorer, the time is an hour longer than specified.
Code: Select all
Date.q = Date(2010, 4, 8, 2, 0, 0)
File.s = GetTemporaryDirectory()+"Test.txt"
CreateFile(0, File)
CloseFile(0)
SetFileDate(File, #PB_Date_Created, Date)
Debug FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", Date)
Debug FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", GetFileDate(File, #PB_Date_Created))
RunProgram(GetTemporaryDirectory())
Re: SetFileDate() and GetFileDate()
Posted: Mon Feb 12, 2024 11:18 pm
by juergenkulow
Code: Select all
; SetFileDate Linux
File.s = GetTemporaryDirectory()+"Test.txt"
CreateFile(0, File)
CloseFile(0)
Debug FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", GetFileDate(File, #PB_Date_Created))
Debug FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", GetFileDate(File, #PB_Date_Modified))
Debug FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", GetFileDate(File, #PB_Date_Accessed))
date=Date(2024,2,13,14,15,16)
SetFileDate(File, #PB_Date_Modified, date)
Debug FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", GetFileDate(File, #PB_Date_Created))
Debug FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", GetFileDate(File, #PB_Date_Modified))
Debug FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", GetFileDate(File, #PB_Date_Accessed))
SetFileDate(File, #PB_Date_Created, date)
Debug FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", GetFileDate(File, #PB_Date_Created))
Debug FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", GetFileDate(File, #PB_Date_Modified))
Debug FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", GetFileDate(File, #PB_Date_Accessed))
SetFileDate(File, #PB_Date_Accessed, date)
Debug FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", GetFileDate(File, #PB_Date_Created))
Debug FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", GetFileDate(File, #PB_Date_Modified))
Debug FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", GetFileDate(File, #PB_Date_Accessed))
; 2024/02/12 23:14:50
; 2024/02/12 23:14:50
; 1970/01/01 00:00:00
; 2024/02/13 14:15:16
; 2024/02/13 14:15:16
; 1970/01/01 00:00:00
; 1970/01/01 00:00:00
; 1970/01/01 00:00:00
; 1970/01/01 00:00:00
; 1970/01/01 00:00:00
; 1970/01/01 00:00:00
; 1970/01/01 00:00:00
Re: SetFileDate() and GetFileDate()
Posted: Wed Feb 14, 2024 6:29 am
by Lebostein
same on mac OS
Code: Select all
2024/02/14 06:28:47
2024/02/14 06:28:47
1970/01/01 00:00:00
2024/02/13 14:15:16
2024/02/13 14:15:16
1970/01/01 00:00:00
1970/01/01 00:00:00
1970/01/01 00:00:00
1970/01/01 00:00:00
1970/01/01 00:00:00
1970/01/01 00:00:00
1970/01/01 00:00:00
Re: SetFileDate() and GetFileDate()
Posted: Sat Mar 02, 2024 10:38 am
by Fred
When you use an absolute date, there is no timezone info in it. As you can see GetFileDate(File, #PB_Date_Created) returns 1270692000 which is the correct EPOCH time for Apr 08 02:00:00 2010. Explorer probably display the time using the current timezone, that's why it's different.
Re: SetFileDate() and GetFileDate()
Posted: Sat Mar 02, 2024 6:23 pm
by juergenkulow
Linux:
Code: Select all
2024/03/02 17:50:14
2024/03/02 17:50:14
1970/01/01 00:00:00
2024/02/13 14:15:16 <----- reads #PB_Date_Modified not #PB_Date_Created
2024/02/13 14:15:16
1970/01/01 00:00:00
1970/01/01 00:00:00 <----- #PB_Date_Created missing
1970/01/01 00:00:00
1970/01/01 00:00:00
1970/01/01 00:00:00 <------ #PB_Date_Created missing
1970/01/01 00:00:00
1970/01/01 00:00:00 <------ #PB Date_Accessed not set
After SetFileDate(File, #PB_Date_Modified, date) Date created and Date modified are different :

After SetFileDate(File, #PB_Date_Created, date) :

After SetFileDate(File, #PB_Date_Accessed, date) :
