Skip to content

Commit

Permalink
#1301: Fix relative timestamp issue of SenML decoder.
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslawLegierski authored and sbernard31 committed Aug 31, 2022
1 parent a9e1741 commit b14a740
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*******************************************************************************/
package org.eclipse.leshan.senml;

import java.util.concurrent.TimeUnit;

/**
* Utility class used to resolve SenML record.
*
Expand Down Expand Up @@ -49,7 +51,7 @@ public T resolve(SenMLRecord record) throws SenMLException {
// A negative value indicates seconds in the past from roughly "now".
// Positive values up to 2**28 indicate seconds in the future from "now".
if (resolvedTimestamp < 268_435_456) {
resolvedTimestamp = currentTimestamp + resolvedTimestamp;
resolvedTimestamp = TimeUnit.MILLISECONDS.toSeconds(currentTimestamp) + resolvedTimestamp;
}
// else
// Values greater than or equal to 2**28 represent an absolute time relative to the Unix epoch
Expand Down

0 comments on commit b14a740

Please sign in to comment.