Open
Description
Description
While working on an aura enabled apex method that takes in an Apex Date, I passed in a JS Date object from my LWC. This was accidental, as usually I'd pass in an ISO date string. To my surprise the parser allowed it! But oddly, the Date in apex had an associated time. Normally, when you System.debug
a date, it has a 0 time, but this Date had an actual time.
This is a pretty big issue as logic dependent on Dates such as checking if start and end DateTimes overlaps with the Date can fail dependent on time of day. In my case, the Date had a time around UTC 19:00 and thus a lot of logic would fail.
I'm sure this is more an Apex issue, so feel free to forward the info to the Apex team and close this issue
Steps to Reproduce
//Apex
@AuraEnabled(Cacheable=true)
Public static void test(Date d){
System.debug(d);
}
//LWC
date = new Date();
@wire(test,{d:'$date'})
wiredTest;
Workaround
Just turn the date into an ISO string.
Activity