freebasic/fbc

Date Format Bug

nsiatras opened this issue · 2 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

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

jayrm commented

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