Date Extended
Date Extended
Dear Fred,
many people use the Date library, however, you once decided to make it not support the dates before 1970. I do not know wheter this is an official limitation dictated by the creators of the Unix Time Stamp, but it is odd if you want to store birth dates, etc. that may be before 1970.
Also you must be aware of the 2038-problem.
Would it not be time, since many people now use and are common to 64 Bit, to use a 64 time stamp? I know it might seem like overkill, but the 136 years of 32 Bit are too few!
Also think about enabling the years before 1970 so that the Date library can be usefull at all. In fact, I propably had not made this post if the possible range of the 32 Bit stamp would be completely used, providing date support back until 1902.
Thanks.
many people use the Date library, however, you once decided to make it not support the dates before 1970. I do not know wheter this is an official limitation dictated by the creators of the Unix Time Stamp, but it is odd if you want to store birth dates, etc. that may be before 1970.
Also you must be aware of the 2038-problem.
Would it not be time, since many people now use and are common to 64 Bit, to use a 64 time stamp? I know it might seem like overkill, but the 136 years of 32 Bit are too few!
Also think about enabling the years before 1970 so that the Date library can be usefull at all. In fact, I propably had not made this post if the possible range of the 32 Bit stamp would be completely used, providing date support back until 1902.
Thanks.
Re: Date Extended
+1
Linux Mint 21.1 Vera base: Ubuntu 22.04 jammy.
PureBasic 6.02 LTS (Linux - x64)
PureBasic 6.02 LTS (Linux - x64)
Re: Date Extended
I also vote for extending the the date functions to 64 bit.
The limit to the year 2038 makes the current lib unusable for many applications. The limitation applies also to the DateGadget().
The limit to the year 2038 makes the current lib unusable for many applications. The limitation applies also to the DateGadget().
PB 6.02 x64, OS: Win 7 Pro x64 & Win 11 x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age in 2024: 56y
"Happiness is a pet." | "Never run a changing system!"
"Happiness is a pet." | "Never run a changing system!"
Re: Date Extended
+1
In fact, birthdays < 1970 are not rare...
In fact, birthdays < 1970 are not rare...
Re: Date Extended
Workaround: http://www.purebasic.fr/english/viewtop ... 08#p105008kurzer wrote:The limitation applies also to the DateGadget().
Re: Date Extended
Hello,
I had the problem storing a timestamp in MS SQL Server which has 64bit-signed numbers.
The codes below are not for copy'n'paste'n'run as usual; but You don't want to use them either without checking.
Here is the mapping:
63bits are used -> signed! (one bit for upper or lower 0).
The following one uses ticks as re-get timestamp in one millisecond (approx. 100 possible, 8191 available):
Another procedure:
The MS SQL Server does not support static variables for the ticks nor global variables.
But with functions, it works; but the ticks have to be created from PB.
The problem came around when I tried to write 64bit from MS Access/MS Excel -> not possible...
Regards
I had the problem storing a timestamp in MS SQL Server which has 64bit-signed numbers.
The codes below are not for copy'n'paste'n'run as usual; but You don't want to use them either without checking.
Here is the mapping:
Code: Select all
Procedure.q new63bitDT(PYear=0, PMonth=0, PDay=0, PHour=0, PMinute=0, PSecond=0, PMilliSecond=0, PTick=0)
Protected R.q = 0
Protected Y.q = PYear << 49,
Mo.q = PMonth << 45,
D.q = PDay << 40,
H.q = PHour << 35,
Mi.q = PMinute << 29,
S.q = PSecond << 23,
Ms.q = PMilliSecond << 13,
Ti.q = PTick
R = Y + Mo + D + H + Mi + S + Ms + Ti
;debug "P; Y:" + Str(PYear) + "; Mo:" + Str(PMonth) + "; D:" + Str(PDay) + "; H:" + Str(PHour) + ";" +
; " Mi:" + Str(PMinute) + "; S:" + Str(PSecond) + "; Ms:" + Str(PMilliSecond) + "; Ti:" + Str(PTick)
;debug "Y:" + Str(Y) + "; Mo:" + Str(Mo) + "; D:" + Str(D) + "; H:" + Str(H) + "; Mi:" + Str(Mi) + "; S:" + Str(S) + "; Ms:" + Str(Ms) + "; Ti:" + Str(Ti) + "; R:" + Str(R)
ProcedureReturn R
EndProcedure
The following one uses ticks as re-get timestamp in one millisecond (approx. 100 possible, 8191 available):
Code: Select all
Procedure.q new63bitTS(UseTicks=#True)
static LastR.q = 0, ; store last given TS for tick check
LastTicks = 0
Protected R.q = 0,
Now = Date(),
Y = Year(Now),
Mo= Month(Now),
D = Day(Now),
H = Hour(Now),
Mi= Minute(Now),
S = Second(Now),
Ms= get_Milliseconds(),
Ti=0
R = new63bitDT(Y, Mo, D, H, Mi, S, Ms)
if UseTicks ;debug Str(LastR) + ";" + Str(R | 8191)
if LastR = (R | 8191) ; same until ms
LastTicks + 1
R = R | LastTicks
else
LastTicks=0
endif
endif
LastR = R | 8191
ProcedureReturn R
EndProcedure
Code: Select all
Procedure.q DateTime_to63bit(P)
Protected R.q,
Y = Year(P),
Mo = Month(P),
D = Day(P),
H = Hour(P),
Mi = Minute(P),
S = Second(P),
Ms = 0,
Ti = 0
Protected qY.q = Y << 49,
qMo.q = Mo << 45,
qD.q = D << 40,
qH.q = H << 35,
qMi.q = Mi << 29,
qS.q = S << 23,
qMs.q = Ms << 13,
qTi.q = Ti
R = qY + qMo + qD + qH + qMi + qS + qMs + qTi
ProcedureReturn R
EndProcedure
But with functions, it works; but the ticks have to be created from PB.
The problem came around when I tried to write 64bit from MS Access/MS Excel -> not possible...
Regards
Re: Date Extended
And converting back...
Code: Select all
Procedure yearFrom63bitDT(DT.q)
procedureReturn (DT & (4095 << 49)) >> 49
EndProcedure
Procedure monthFrom63bitDT(DT.q)
procedureReturn (DT & (15 << 45)) >> 45
EndProcedure
Procedure dayFrom63bitDT(DT.q)
procedureReturn (DT & (31 << 40)) >> 40
EndProcedure
Procedure hourFrom63bitDT(DT.q)
ProcedureReturn (DT & (31 << 35)) >> 35
EndProcedure
Procedure minuteFrom63bitDT(DT.q)
procedureReturn (DT & (63 << 29)) >> 29
EndProcedure
Procedure secondFrom63bitDT(DT.q)
procedureReturn (DT & (63 << 23)) >> 23
EndProcedure
Procedure.q minute_To63bit(Value.i)
Protected R.q
R = Value << 29
ProcedureReturn R
EndProcedure
Procedure millisecondFrom63bitDT(DT.q)
procedureReturn (DT & (1023 << 13)) >> 13
EndProcedure
Procedure tickFrom63bitDT(DT.q)
procedureReturn (DT & 8191)
EndProcedure
Re: Date Extended
+1
Leave date() library alone and create a new date64() library:
and don't forget visual: ( gadgets )
I think it will be easier to create a new library instead of breaking old code that works.
I know if you search the forums you'll find bits and pieces of all this stuff but if you are new to PureBasic you dont want to run around looking for a date library that handles < 1970. Adding this would make PureBasic a more accesible compiler.
Leave date() library alone and create a new date64() library:
Code: Select all
AddDate64()
Date64()
Day64()
DayOfWeek64()
DayOfYear64()
FormatDate64()
Hour64()
Minute64()
Month64()
ParseDate64()
Second64()
Year64()
Code: Select all
DateGadget64()
SetGadgetState64()
SetGadgetText64()
GetGadgetState64()
GetGadgetText64()
GetGadgetAttribute64()
SetGadgetAttribute64()
SetGadgetColor64()
GetGadgetColor64()
I know if you search the forums you'll find bits and pieces of all this stuff but if you are new to PureBasic you dont want to run around looking for a date library that handles < 1970. Adding this would make PureBasic a more accesible compiler.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
Re: Date Extended
Any cross-platform way to solve this?
<1970 and >2038
The available workarounds do not include the date gadget.
<1970 and >2038
The available workarounds do not include the date gadget.
Re: Date Extended
Would this masterpiece by wilbert be of interest?
http://www.purebasic.fr/english/viewtop ... 31#p421423
http://www.purebasic.fr/english/viewtop ... 31#p421423
DE AA EB
Re: Date Extended
Translated by google.
+ 1 For a cross-platform solution!
And how to use dates before our era?
Examples date for ancient history (wiki source) :
Around 3800 BC. - Copper Age.
Around 2500 BC. - Bronze Age.
Around 1200 BC. - Iron Age.
Around 3300 BC. - Sumerian civilization of Mesopotamia.
Around 3100 BC. - unification of Egypt by Narmer.
Around 2500 BC. - height of the Indus civilization.
And how to use geological dates?
En Français
+1 Pour une solution multiplate-formes !
Et comment traiter les dates avant notre ére ?
Exemples de date pour l'histoire antique (source wiki) :
Vers 3800 av. J.-C. - âge du cuivre.
Vers 2500 av. J.-C. - âge du bronze.
Vers 1200 av. J.-C. - âge du fer.
Vers 3300 av. J.-C. - la civilisation sumérienne de Mésopotamie.
Vers 3100 av. J.-C. - unification de l’Égypte par Narmer.
Vers 2500 av. J.-C. - apogée de la civilisation de l’Indus.
Et comment traiter les dates géologiques ?
+ 1 For a cross-platform solution!
And how to use dates before our era?
Examples date for ancient history (wiki source) :
Around 3800 BC. - Copper Age.
Around 2500 BC. - Bronze Age.
Around 1200 BC. - Iron Age.
Around 3300 BC. - Sumerian civilization of Mesopotamia.
Around 3100 BC. - unification of Egypt by Narmer.
Around 2500 BC. - height of the Indus civilization.
And how to use geological dates?
En Français
+1 Pour une solution multiplate-formes !
Et comment traiter les dates avant notre ére ?
Exemples de date pour l'histoire antique (source wiki) :
Vers 3800 av. J.-C. - âge du cuivre.
Vers 2500 av. J.-C. - âge du bronze.
Vers 1200 av. J.-C. - âge du fer.
Vers 3300 av. J.-C. - la civilisation sumérienne de Mésopotamie.
Vers 3100 av. J.-C. - unification de l’Égypte par Narmer.
Vers 2500 av. J.-C. - apogée de la civilisation de l’Indus.
Et comment traiter les dates géologiques ?
Re: Date Extended
Yes thanks, davido. I have my hands on it already.davido wrote:Would this masterpiece by wilbert be of interest?
http://www.purebasic.fr/english/viewtop ... 31#p421423
PB 6.02 x64, OS: Win 7 Pro x64 & Win 11 x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age in 2024: 56y
"Happiness is a pet." | "Never run a changing system!"
"Happiness is a pet." | "Never run a changing system!"
Re: Date Extended
Simple: Use a String or when you only save the year use an integer. The time and date measuring has changed during our history. So it doesn't make sence to use our current system with such old dates.Ulix wrote:And how to use dates before our era?
btw. DateQ would make more sence then Date64