pkg icon indicating copy to clipboard operation
pkg copied to clipboard

date.toLocaleDateString() returns date without zeros even if locale is provided

Open ealexandrohin opened this issue 3 years ago • 0 comments

What version of pkg are you using?

5.8.0

What version of Node.js are you using?

v18.7.0

What operating system are you using?

Windows 10

What CPU architecture are you using?

x86_64

What Node versions, OSs and CPU architectures are you building for?

fetched-v18.5.0-win-x64

Describe the Bug

When you create new Date() and getting locale date string with or without specified locale, it returns date without zeros in days and months in exe.

const now = new Date();
console.log(now.toLocaleDateString(), now.toLocaleDateString('en-GB')); // 9/9/2022 9/9/2022

As you can see its the same. But, as script, the same, it returns with zeros in both cases:

const now = new Date();
console.log(now.toLocaleDateString(), now.toLocaleDateString('en-GB')); // 09/09/2022 09/09/2022

2022-09-09_19-14

Expected Behavior

Should return date with zeros in days and months, as it is in script.

To Reproduce

const now = new Date();
console.log(now.toLocaleDateString(), now.toLocaleDateString('en-GB'));

Run it youself and then build it and exec it and see the difference.

ealexandrohin avatar Sep 09 '22 16:09 ealexandrohin