fbc icon indicating copy to clipboard operation
fbc copied to clipboard

Date Format Bug

Open nsiatras opened this issue 3 years ago • 1 comments

I just noticed that the following code

#include "vbcompat.bi"
print format (now,"d/m/yyyy")

Outputs

15-10-2022

But the correct output should be

15/10/2022

It seems that the Formatting ignores the "/ " character

nsiatras avatar Oct 15 '22 18:10 nsiatras

PS.

I think I found the bug.. I just noticed that the format command replaces the "/" with "-"

The following code

#include "vbcompat.bi"
print format (now,"d//m//yyyy")

Outputs

15--10--2022

The

#include "vbcompat.bi"
print format (now,"d_m_yyyy")

Output is correct

15_10_2022

So I think the problem is only when date parts are separated with the "/" character

nsiatras avatar Oct 15 '22 18:10 nsiatras

Thanks for the report. This is not bug.

Time and date separators ( ':' and '/' ) are place holders for the operating system defined separators. Either regional or localized settings (even on DOS supporting extended country code information).

To force literal output of a character without modification, prefix the character with \ backslash.

For example

print format (now,"d\/m\/yyyy")

OUTPUT:
31/12/2022

Note added to wiki: https://www.freebasic.net/wiki/KeyPgFormat

jayrm avatar Dec 31 '22 20:12 jayrm