Skip to content

Commit

Permalink
Merge pull request #10 from GeoTecINIT/to-timestamp
Browse files Browse the repository at this point in the history
BREAKING CHANGE: timestamp type from Date to number
  • Loading branch information
matey97 authored May 13, 2022
2 parents dc1d636 + 8731fa0 commit c590339
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions demo/app/tests/internal/sensor-callback-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ describe("Sensor callback manager", () => {

const sensorRecordA1: SensorRecord = {
deviceId: "test",
timestamp: new Date()
timestamp: Date.now()
};
const sensorRecordA2: SensorRecord = {
deviceId: "test",
timestamp: new Date()
timestamp: Date.now()
};
const sensorRecordB1: SensorRecord = {
deviceId: "test",
timestamp: new Date()
timestamp: Date.now()
};
const noNotificationTimeout = 100;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("Heart rate record messaging service", () => {

function getFakeHeartRateData() {
return {
timestamp: new Date(),
timestamp: Date.now(),
value: Math.floor(Math.random() * 100),
};
}
Expand All @@ -51,7 +51,7 @@ function buildFakeEncodedMessage(expectedRecords: HeartRateSensorRecord[]) {
buff.putInt(expectedRecords.length);
expectedRecords.forEach((record) => {
buff.putInt(record.value);
buff.putLong(record.timestamp.getTime());
buff.putLong(record.timestamp);
})

return bytes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("Location record messaging service", () => {

function getFakeLocationData() {
return {
timestamp: new Date(),
timestamp: Date.now(),
latitude: 39.9939752904,
longitude: -0.0741332084749,
altitude: 20,
Expand All @@ -57,7 +57,7 @@ function buildFakeEncodedMessage(expectedRecords: LocationSensorRecord[]) {
buff.putDouble(record.latitude);
buff.putDouble(record.longitude);
buff.putDouble(record.altitude);
buff.putLong(record.timestamp.getTime());
buff.putLong(record.timestamp);
})

return bytes;
Expand Down
4 changes: 2 additions & 2 deletions demo/app/tests/internal/sensors/triaxial/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TriAxialSensorRecord } from "nativescript-wearos-sensors/internal/senso

export function getFakeTriAxialData() {
return {
timestamp: new Date(),
timestamp: Date.now(),
x: Math.random(),
y: Math.random(),
z: Math.random(),
Expand All @@ -20,7 +20,7 @@ export function buildFakeEncodedMessage(expectedRecords: TriAxialSensorRecord[])
buff.putFloat(record.x);
buff.putFloat(record.y);
buff.putFloat(record.z);
buff.putLong(record.timestamp.getTime());
buff.putLong(record.timestamp);
})

return bytes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class HeartRateRecordMessagingService extends AbstractRecordMessagingServ

records.push({
deviceId: messageEvent.getSourceNodeId(),
timestamp: new Date(time),
timestamp: time,
value,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class LocationRecordMessagingService extends AbstractRecordMessagingServi

records.push({
deviceId: messageEvent.getSourceNodeId(),
timestamp: new Date(time),
timestamp: time,
latitude: lat,
longitude: lon,
altitude: alt,
Expand Down
2 changes: 1 addition & 1 deletion src/internal/sensors/sensor-record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SensorType } from "./sensor-type";

export interface SensorRecord {
deviceId: string;
timestamp: Date;
timestamp: number;
}

export interface SensorRecords<T extends SensorRecord> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class TriAxialRecordMessagingService extends AbstractRecordMessagingServi
time = buff.getLong();
records.push({
deviceId: messageEvent.getSourceNodeId(),
timestamp: new Date(time),
timestamp: time,
x,
y,
z,
Expand Down
4 changes: 2 additions & 2 deletions src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-wearos-sensors",
"version": "2.0.0",
"version": "3.0.0",
"description": "Your awesome NativeScript plugin.",
"main": "wearos-sensors",
"typings": "index.d.ts",
Expand Down

0 comments on commit c590339

Please sign in to comment.