Fix TimeWithinDay(t) abstract operation (#3974)
Fixes #3973. TimeWithinDay(t) = t modulo msPerDay, where msPerDay = 86400000. The sign of the modulo operation result should be same as the right side per definition, conseqently TimeWithinDay(t) >= 0. References: - https://www.ecma-international.org/ecma-262/11.0/#sec-mathematical-operations - https://www.ecma-international.org/ecma-262/11.0/#sec-overview-of-date-objects-and-definitions-of-abstract-operations JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
This commit is contained in:
committed by
GitHub
parent
392ee71712
commit
5f951bb4f1
@@ -72,7 +72,13 @@ ecma_date_time_within_day (ecma_number_t time) /**< time value */
|
||||
{
|
||||
JERRY_ASSERT (!ecma_number_is_nan (time));
|
||||
|
||||
return (ecma_number_t) fmod (time, ECMA_DATE_MS_PER_DAY);
|
||||
ecma_number_t modulo = fmod (time, ECMA_DATE_MS_PER_DAY);
|
||||
if (modulo < 0)
|
||||
{
|
||||
modulo += ECMA_DATE_MS_PER_DAY;
|
||||
}
|
||||
|
||||
return modulo;
|
||||
} /* ecma_date_time_within_day */
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user