I have a LWC component that is a calendar, he verify the begin and end time of the company to put the interval of this hours, the problem is, when the hour is 00 or 01 or 02.. because of the way that was made. He considered only the hour ignoring the minutes and the method is like this:
getFirstHour(milliBegin) {
let hour = milliBegin / 1000 / 60 / 60;
return (Number.isInteger(hour) ? milliBegin : (parseInt(hour) * 60 * 60 * 1000));
}
At first, he send the milliseconds value so imagine:
- 23h = 82800000 (RIGHT!! It works) (CORRECT: 23 * 60 * 60 * 1000)
- 00h = 0 (the right value should be: 86400000) (WRONG: 00 * 60 * 60 * 1000/CORRECT: 24 * 60 * 60 * 1000)
- 01h = 3600000 (the right value should be: 90000000) (WRONG: 01 * 60 * 60 * 1000/CORRECT: 25 * 60 * 60 * 1000)
When I put this right values, before the getFirstHour method be called, it works, because I put this ifs statements:
if(this.dealer.BusinessHourEnd__c == 0){
this.dealer.BusinessHourEnd__c = 86400000;
}
else if(this.dealer.BusinessHourEnd__c == 1){
this.dealer.BusinessHourEnd__c = 90000000;
}
But I don't wanna do several ifs to achieve the right solution.. How can I solved this? I need to used the milliseconds unfortunately because it's only this small bug and I don't have time to correct all this component, and it was built in that way