react-native-worklets-core icon indicating copy to clipboard operation
react-native-worklets-core copied to clipboard

Date object not getting created

Open tremblerz opened this issue 1 year ago • 3 comments

Here is a minimal example to reproduce -

const workletContext = Worklets.defaultContext;
workletContext.runAsync(() => {
    'worklet';
    const day = '2021-09-01';
    console.log('Day is', new Date(day));
});

Output:

Day is {}

tremblerz avatar Aug 26 '24 15:08 tremblerz

Surprisingly, if I perform an operation such as const dateObj = new Date(day); console.log(dateObj.getTime()). It appears to be working fine.

tremblerz avatar Aug 27 '24 01:08 tremblerz

I might be wrong, but I think the console log function just doesn't support multiple arguments in worklets. Have you tried console.log(new Date(day).getTIme()) ?

hannojg avatar Aug 27 '24 07:08 hannojg

So getTime() is generally working anywhere but even if I do

const d = new Date();
console.log(d);

This prints {}

tremblerz avatar Aug 28 '24 01:08 tremblerz