Code: Select all
$ echo print date >datetest.bas
$ fbc datetest
$ ./datetest
03-12-2018
Same bug in the macro __DATE__, so "fbc --version" shows a wrong (or at least ambiguous) compile date.
Luckily we have __DATE_ISO__.
Code: Select all
$ echo print date >datetest.bas
$ fbc datetest
$ ./datetest
03-12-2018
So the right thing to do would be to change both the program and the documentation. It should print the date according to the locale used.dkr wrote:The documentation shows the output is in the format mm-dd-yyyy
DATE DOCUMENTATION
Returns the current system date as a string
Syntax
Declare Function Date ( ) As String
Usage
result = Date
Return Value
Returns the current system date, in the format mm-dd-yyyy
Code: Select all
#include "crt/time.bi"
Function DateString() As String
Dim As time_t rawtime
time_(@rawtime)
Dim As tm Ptr timeinfo=localtime(@rawtime)
Return *asctime(timeinfo)
End Function
Print DateString
sleep
Code: Select all
Function CHDate() ByRef As Const String ' write protected! swiss date format
Static As String CH_Date, cDate ' swiss/current (american) date
If cDate <> Date Then ' date change or first call, only!
cDate = Date ' save current american date (for comparison)
Dim As String dd = Mid(cDate, 4, 2), _ ' part strings: dd = day,
mm = Left(cDate, 2), yy = Right(cdate, 4) ' mm = month, yy = year
CH_Date = dd + "." + mm + "." + yy ' construct CH_Date <-- change here,
End If ' for own/different format! rename procedure! indi-
' cating the change made ... (comments too, please)
Return CH_Date ' swiss style formatted Date-String
End Function
Yes, I get the same resultdodicat wrote:For curiosity, does this work on your system?
Here I get:
Tue Mar 13 23:51:34 2018
But why should I have to do that?MrSwiss wrote:Another approach is, write your own Date-Changer Function as below:Fast and compact ...Code: Select all
Function CHDate() ByRef As Const String ' write protected! swiss date format Static As String CH_Date, cDate ' swiss/current (american) date If cDate <> Date Then ' date change or first call, only! cDate = Date ' save current american date (for comparison) Dim As String dd = Mid(cDate, 4, 2), _ ' part strings: dd = day, mm = Left(cDate, 2), yy = Right(cdate, 4) ' mm = month, yy = year CH_Date = dd + "." + mm + "." + yy ' construct CH_Date <-- change here, End If ' for own/different format! rename procedure! indi- ' cating the change made ... (comments too, please) Return CH_Date ' swiss style formatted Date-String End Function
Because, we aren't all americans ?!? ;-)skogtun wrote:But why should I have to do that?