Strange timing
Strange timing
Dear all, i see a delphi application that have some strange system date management, i just want to know if i can replicate in purebasic, i cannot explain in detail but i can give some value examples:
$40E6000000000000 = 2023/05/10
$40E5000000000000 = 2017/09/30
$40E4000000000000 = 2012/02/21
can anyone help me ? Thanks!
$40E6000000000000 = 2023/05/10
$40E5000000000000 = 2017/09/30
$40E4000000000000 = 2012/02/21
can anyone help me ? Thanks!
Re: Strange timing
That won't be easy
Delphi's time/date is based on:
http://docs.embarcadero.com/products/ra ... eTime.html
Purebasic unfortunately still uses the ancient UNIX 32bit time system that only supports dates between (roughly) 1970 and 2038.
You could write your own conversion routines if you can live with these limitations...
Delphi's time/date is based on:
http://docs.embarcadero.com/products/ra ... eTime.html
Purebasic unfortunately still uses the ancient UNIX 32bit time system that only supports dates between (roughly) 1970 and 2038.
You could write your own conversion routines if you can live with these limitations...
PB 5.73 on Windows 10 & OS X High Sierra
Re: Strange timing
After a bit of experimenting, this seems to work
Code: Select all
Procedure.i ConvertDate(delphiDate.q)
Protected *date.Double = @delphiDate
ProcedureReturn (*date\d + 24142)*86400
EndProcedure
date = ConvertDate($40E6000000000000)
Debug FormatDate("%mm/%dd/%yyyy", date)
date = ConvertDate($40E5000000000000)
Debug FormatDate("%mm/%dd/%yyyy", date)
date = ConvertDate($40E4000000000000)
Debug FormatDate("%mm/%dd/%yyyy", date)
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Strange timing
wilbert wrote:After a bit of experimenting, this seems to workCode: Select all
Procedure.i ConvertDate(delphiDate.q) Protected *date.Double = @delphiDate ProcedureReturn (*date\d + 24142)*86400 EndProcedure date = ConvertDate($40E6000000000000) Debug FormatDate("%mm/%dd/%yyyy", date) date = ConvertDate($40E5000000000000) Debug FormatDate("%mm/%dd/%yyyy", date) date = ConvertDate($40E4000000000000) Debug FormatDate("%mm/%dd/%yyyy", date)
Not here:
Code: Select all
00/00/0000
00/00/0000
00/00/0000
Re: Strange timing
Had to add Int() to make it work:
Code: Select all
Procedure.i ConvertDate(delphiDate.q)
Protected *date.Double = @delphiDate
ProcedureReturn (Int(*date\d) + 24142)*86400
EndProcedure
date = ConvertDate($40E6000000000000)
Debug FormatDate("%mm/%dd/%yyyy", date)
date = ConvertDate($40E5000000000000)
Debug FormatDate("%mm/%dd/%yyyy", date)
date = ConvertDate($40E4000000000000)
Debug FormatDate("%mm/%dd/%yyyy", date)
Re: Strange timing
On x86, you need to change the return type to quad.
Re: Strange timing
So if the integer conversion procedure would also be required on some OS, it would be likefryquez wrote:On x86, you need to change the return type to quad.
Code: Select all
Procedure.q ConvertDate(delphiDate.q)
Protected *date.Double = @delphiDate
ProcedureReturn IntQ((*date\d + 24142)*86400)
EndProcedure
date = ConvertDate($40E6000000000000)
Debug FormatDate("%mm/%dd/%yyyy", date)
date = ConvertDate($40E5000000000000)
Debug FormatDate("%mm/%dd/%yyyy", date)
date = ConvertDate($40E4000000000000)
Debug FormatDate("%mm/%dd/%yyyy", date)
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Strange timing
Thanks to all, i'll try as soon as possible!
sorry, i try to understand the code, you take the pointer of quad value and insert as pointer in a double value (in fact if i read bytes from double contents i see the same of bytes of quad contents), but i don't understand *date\d, what conversion do ?
sorry, i try to understand the code, you take the pointer of quad value and insert as pointer in a double value (in fact if i read bytes from double contents i see the same of bytes of quad contents), but i don't understand *date\d, what conversion do ?