Compatibility of GetDate

Feature requests for future versions of Hollywood can be voiced here
Post Reply
User avatar
Juan Carlos
Posts: 784
Joined: Mon Sep 06, 2010 1:02 pm

Compatibility of GetDate

Post by Juan Carlos »

With the code is more clean:

Code: Select all

PROBLEM WITH THE DATE FORMAT USED BY HOLLYWOOD AND THE AMIGA SYSTEMS

;Format dates:
;"jueves 10-nov-22 12:51:49" ;Format got from a file save with: Execute("Date >ENVARC:MiHora")
;"11-Nov-2022 12:51:49" ;Format from computer clock and Hollywood.

;We make the MiHora file:
Execute("Date >ENVARC:MiHora")

;Get computer date and hour:
FechaSystem$=GetDate(#DATELOCAL)

;Get the date from the file created with Execute on MorphOS or AmigaOS3.9
OpenFile(1, "ENVARC:MiHora", #MODE_READ)
While Not Eof(1) Do FechaFile$=ReadString(1)
CloseFile(1)

;Here is the problem with the different format, even when you with the
;instruction RightStr(FechaFile$, 19) you remove the day "jueves" from
;from the string but the problem is the month "nov" for example in lower
;letter because Hollywood uses "Nov".

ResultaCompara=CompareDates(FechaFile$, FechaSystem$)

;The CompareDates only compare full dates in the format dd-mmm-yyyy hh:mm:ss
;but with the month in capital letter.
The question is the different format between Hollywood and the date system in the month, it is curiously that Hollywood uses the Months and the system uses the months, the difference the first letter capital letter on Hollywood lower case on the system.
Flinx
Posts: 90
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Compatibility of GetDate

Post by Flinx »

Because Hollywood is a cross platform environment, I think it is impossible to have compatibility to all date formats. If the built-in functions can't be used for some reason, I would request an enhancement there.
But why can't you use GetDate(#DATELOCAL)? With this function you get code that works on much more target machines. Even on Amiga the date format seems not to be consistent, at least in German OS 3.1 I get an upper case Nov.
And if you really need to use the date command then you could use LowerStr() for both strings before comparing.
User avatar
Juan Carlos
Posts: 784
Joined: Mon Sep 06, 2010 1:02 pm

Re: Compatibility of GetDate

Post by Juan Carlos »

Thank you for your suggestion to convert both string with LowerStr().
User avatar
Juan Carlos
Posts: 784
Joined: Mon Sep 06, 2010 1:02 pm

Re: Compatibility of GetDate

Post by Juan Carlos »

The instruction LowerStr convert the month in lowercase letter, but CompareDates only world with months in capital letter.
Flinx
Posts: 90
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Compatibility of GetDate

Post by Flinx »

Sorry, I should have tried. Here you have a working solution:

Code: Select all

FechaFile$="jueves 10-nov-22 12:51:49"
FechaSystem$="11-Nov-2022 12:51:49"
FechaFile$=PatternReplaceStr(PatternReplaceStr(PatternReplaceStr(FechaFile$, "(%-%a)", UpperStr), "%a+ ", ""), "(%d+%-%a+%-)(%d%d) ", "%120%2 ")
DebugPrint(CompareDates(FechaFile$, FechaSystem$))
Should I explain that?

Nevertheless I think that using

Code: Select all

GetDate(#DATELOCAL)
would be the better solution than Execute("Date >ENVARC:MiHora").
User avatar
Juan Carlos
Posts: 784
Joined: Mon Sep 06, 2010 1:02 pm

Re: Compatibility of GetDate

Post by Juan Carlos »

The solution of Execute("Date >ENVARC:MiHora") has its explain I have problems with my PowerBook and MacMini with the clock battery and I found this solution to save the date and recover it, in my little tool BootClock, using the date from MorphOS system for after recover the date with the system instruction Date.
Flinx
Posts: 90
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Compatibility of GetDate

Post by Flinx »

Understand, that's a reason.
Post Reply