Replace __DATE__ with __DATE_ISO:__

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
skogtun
Posts: 13
Joined: Dec 22, 2010 19:53

Replace __DATE__ with __DATE_ISO:__

Post by skogtun »

src/sompiler/fb.bi:

const FB_BUILD_DATE = __DATE__

This is ambiguous. None but Americans use the date format MM/DD/YY.

Replace with

const FB_BUILD_DATE = __DATE_ISO__

and everyone should be happy.
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Replace __DATE__ with __DATE_ISO:__

Post by dodicat »

Fb originated from vbdos, the quickbasic family, i.e. Microsoft.
So I suppose fb is naturally American, although the author (V1ctor) would use D/M/Y at his location.
https://en.wikipedia.org/wiki/Date_format_by_country

But it can be adjusted for another location:

Code: Select all


#include "vbcompat.bi"
#define ISODATE format(now,"dd/mm/yyyy")


print isodate 
sleep
 
St_W
Posts: 1619
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Replace __DATE__ with __DATE_ISO:__

Post by St_W »

skogtun wrote:src/sompiler/fb.bi:
const FB_BUILD_DATE = __DATE__
This is ambiguous. None but Americans use the date format MM/DD/YY.
I'd also use a date in ISO 8601 format (which is YYYY-MM-DD) rather than any localized version, but it's a breaking change if we do so.

Anyway, the documentation mentions even a different format (dd-mm-yyyy) for that constant:
http://freebasic.net/wiki/wikka.php?wak ... BBuildDate

So is the documentation wrong. If so the breaking change would be even less important, because it could be rather considered as a fix.
fxm
Moderator
Posts: 12082
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Replace __DATE__ with __DATE_ISO:__

Post by fxm »

St_W wrote:Anyway, the documentation mentions even a different format (dd-mm-yyyy) for that constant:
http://freebasic.net/wiki/wikka.php?wak ... BBuildDate
No, the documentation specifies the correct format of the returned date: MM-DD-YYYY
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Replace __DATE__ with __DATE_ISO:__

Post by dodicat »

Sorry, I got the wrong end of the stick.
I am on NOW, not then.
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Replace __DATE__ with __DATE_ISO:__

Post by Tourist Trap »

Using a macro would allow a renaming on demand without any breach on the backward compatibility:

Code: Select all

#undef __DATE_ISO__

#macro  __DATE_ISO__
   str(__DATE__)
#endmacro

? __DATE_ISO__
Maybe of course I miss the crucial point.
Post Reply