Page 1 of 2

Re: Extended Date [Windows, Linux, MacOS]

Posted: Thu Aug 10, 2017 7:23 am
by Lord
wilbert wrote:...

Code: Select all

...
It's Julian/Gregorian hybrid with a fixed cutover date of Oct 4/15, 1582.
It should be accurate up to a few million years.
It's fast, cross platform, no ASM and no API. :)
That is not a good idea. The transition from Julian to Gregorian is depending on the location.
In parts of northern europe the cutover date is Feb 19/28 1700.
In Greece in the year 1923, in China in 1949 ....

Re: Extended Date [Windows, Linux, MacOS]

Posted: Thu Aug 10, 2017 8:23 am
by wilbert
Lord wrote:That is not a good idea. The transition from Julian to Gregorian is depending on the location.
In parts of northern europe the cutover date is Feb 19/28 1700.
In Greece in the year 1923, in China in 1949 ....
Fortunately we all are entitled to our own opinions. :wink:
To me a transition depending on location seems like a bad idea.
If I store a date inside a program that something happened here on for example July 2nd, 1901 and someone in Greece gets presented a different date, things get very confusing. To me consistency is the most important thing.
I've seen the link Sicro quoted to the German forum with a function handling local cutover dates but if I'm not mistaken, such a table is only useful if you are programming the entire date system yourself.
If you combine it for example with the internal date system of Linux, you can skip a few days based on location but the leap days before that date are still wrong so the system still doesn't present the right local dates. :?
An alternative could be to use the ISO 8601 proleptic Gregorian calendar system which makes things a lot easier.

Re: Extended Date [Windows, Linux, MacOS]

Posted: Fri Aug 11, 2017 7:22 am
by Lord
wilbert wrote:
Lord wrote:...
Fortunately we all are entitled to our own opinions.
...
That's true.
I made my statement and leave you your opinion.

Re: Extended Date [Windows, Linux, MacOS]

Posted: Fri Aug 11, 2017 10:55 am
by wilbert
Lord wrote:That's true.
I made my statement and leave you your opinion.
Well, you did get me thinking and reading some more :wink:
From what I understand, PHP, MySQL, JavaScript, Python all use a proleptic Gregorian calendar.
It would make sense to use the same.

Re: Extended Date [Windows, Linux, MacOS]

Posted: Sat Aug 12, 2017 10:20 am
by Lord
wilbert wrote:...
From what I understand, PHP, MySQL, JavaScript, Python all use a proleptic Gregorian calendar.
It would make sense to use the same.
So, if all are doing the same error, it is wise to make the same?
Why not doing it better and avoid possible problems?

But, as I said, it's just my opinion.

Re: Extended Date [Windows, Linux, MacOS]

Posted: Sun Sep 10, 2017 12:01 am
by Sicro
There are a few other projects that I want to finish first. Before I can deal with this issue again.
But I think now and then about how best to handle the time calculations.

https://www.youtube.com/watch?v=-5wpm-gesOY :lol:
It is very complex :(

Re: Extended Date [Windows, Linux, MacOS]

Posted: Sun Sep 10, 2017 9:00 am
by Lord
Sicro wrote:There are a few other projects that I want to finish first. Before I can deal with this issue again.
But I think now and then about how best to handle the time calculations.

https://www.youtube.com/watch?v=-5wpm-gesOY :lol:
It is very complex :(
Who said live is easy? :wink:

Re: Extended Date [Windows, Linux, MacOS]

Posted: Tue Oct 17, 2017 6:08 am
by Olliv
Ten years ago, I remembered a subject of a monthly book named "Sciences & Vie" (published near 1995).

The null point was Monday, January the 1st 1901.
And all consisted in adding and calculate the modulo 7. Dobro (renamed Zorro) told us the problem of a different february every 400 years, what it allowed me to make this :

Code: Select all

Global Dim Jour.S(6)
Jour(0) = "Lundi"
Jour(1) = "Mardi"
Jour(2) = "Mercredi"
Jour(3) = "Jeudi"
Jour(4) = "Vendredi"
Jour(5) = "Samedi"
Jour(6) = "Dimanche"

Procedure Equ(a, b)
 Protected s.L
 s = 0: If a = b: s = 1: EndIf
 ProcedureReturn s
EndProcedure

; Merci Dobro pour cet algo!
Procedure.L Bissex(x.L)
 Protected Result.L
 Result = (1 - Equ((x % 100), 0) )
 Result | Equ(((x >> 2) % 100), 0)
 Result & Equ((x % 4), 0)
 ProcedureReturn Result
EndProcedure

Procedure JoursDansUnMois(x.L, y.L)
 Protected Result.L
 Result = (30 + ((x & 1) ! (x / 8) ) )
 Result - (Equ(x, 2) * (2 - y) )
 ProcedureReturn Result
EndProcedure

Procedure.L JourJ(JJ.L, MM.L, AA.L)
 Protected JPM.L
 Protected J.L
 J = 0
 JPM = 0
 For i = 1900 To AA - 1: J + (365 + Bissex(i) ): Next
 For i = 1 To MM - 1: J + JoursDansUnMois(i, Bissex(AA) ):
Next
 J = ((J + JJ) - 1) % 7
 ProcedureReturn J
EndProcedure
Date$ = InputRequester("Saisie d'une date", "JJ/MM/AAAA",
"01/01/ 1900")
Debug Jour(JourJ(Val(StringField(Date$, 1, "/") ), Val
(StringField(Date$, 2, "/") ), Val(StringField(Date$, 3,
"/") ) ) ) + " " + Date$
(source)And Fred created BOOL() function which can replace Equ() procedure and simplify this also.