Android Question Clarion date conversion

cgili14

Member
Hi!
I'm trying to convert a date from Clarion format (80328 02/12/2020) to a date in b4a.
It's a kind of julian date, any ideas?


Thanks in advance!
 

cgili14

Member
Hi Erel!
The number represents number of day since 01/01/1801.
4 = 01/01/1801
5 = 02/01/1801
...
...
80328 = 02/12/2020
80329 = 03/12/2020
 
Upvote 0

Sandman

Well-Known Member
Licensed User

1607007025394.png
 
Upvote 0

Erel

Administrator
Staff member
Licensed User
B4X:
Sub AppStart (Args() As String)
    Log(DateTime.Date(ClarionToTicks(4)))
    Log(DateTime.Date(ClarionToTicks(5)))
    Log(DateTime.Date(ClarionToTicks(80328)))
    Log(DateTime.Date(ClarionToTicks(80329)))
End Sub

Sub ClarionToTicks (Clarion As Long) As Long
    Dim t As Long = DateUtils.SetDate(1801, 1, 1)
    Dim p As Period
    p.Days = Clarion - 4
    Return DateUtils.AddPeriod(t, p)
End Sub
 
Upvote 0

cgili14

Member
Thanks to both!
I didn't know that dateutils.AddPeriod exists

B4X:
'15/01/2020
Deu.FechaVencimientoJubilados = 80006
Dim per As Period
per.Days = Deu.FechaVencimientoJubilados-4
Log(DateTime.Date(DateUtils.AddPeriod(DateTime.DateParse("01/01/1801"), per)))

It works!! Thanks!
 
Upvote 0
Top