Compare commits

..

6 Commits

Author SHA1 Message Date
f6be9b71f1 3.0.5 2018-11-23 19:26:42 +01:00
9c2d584170 fix(core): update 2018-11-23 19:26:41 +01:00
10bff069c1 3.0.4 2018-11-23 18:48:08 +01:00
8f6272eca4 fix(core): update 2018-11-23 18:48:07 +01:00
f02df7789c 3.0.3 2018-11-23 18:29:38 +01:00
d720b8b084 fix(core): update 2018-11-23 18:29:38 +01:00
8 changed files with 66 additions and 43 deletions

View File

@ -135,13 +135,3 @@ pages:
paths: paths:
- public - public
allow_failure: true allow_failure: true
windowsCompatibility:
image: stefanscherer/node-windows:10-build-tools
stage: metadata
script:
- npm install & npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- windows
allow_failure: true

26
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smarttime", "name": "@pushrocks/smarttime",
"version": "3.0.2", "version": "3.0.5",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -251,14 +251,14 @@
} }
}, },
"@types/luxon": { "@types/luxon": {
"version": "1.4.0", "version": "1.4.1",
"resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-1.4.0.tgz", "resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-1.4.1.tgz",
"integrity": "sha512-jECW+lbzPICLGqN/dBdX6Lwn5s84okwM2EVjcYim7hkh5+Ebej8kjxY7InBlsORNjGe8v7lPpd/88a0qkoEcuA==" "integrity": "sha512-mYv/gbkOJ40CDgR8st5sosfFNrJncdlkpdzQSNRdU86UQg3oWWmll4AO/7B8F5FlBC6YrIXqXDSnkoCBqo+uMA=="
}, },
"@types/node": { "@types/node": {
"version": "10.12.0", "version": "10.12.10",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.10.tgz",
"integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==", "integrity": "sha512-8xZEYckCbUVgK8Eg7lf5Iy4COKJ5uXlnIOnePN0WUwSQggy9tolM+tDJf7wMOnT/JT/W9xDYIaYggt3mRV2O5w==",
"dev": true "dev": true
}, },
"@types/vinyl": { "@types/vinyl": {
@ -718,9 +718,9 @@
"dev": true "dev": true
}, },
"luxon": { "luxon": {
"version": "1.4.3", "version": "1.8.0",
"resolved": "https://registry.npmjs.org/luxon/-/luxon-1.4.3.tgz", "resolved": "https://registry.npmjs.org/luxon/-/luxon-1.8.0.tgz",
"integrity": "sha512-hujVJ+Q2RnaIiHKAupwusgpHXYICxzXJNoPkqkGIfmP+lLZWFTD6gEP+URRs/vh5gI1KwfMimVrzM9309RE0tA==" "integrity": "sha512-F742cYUYB7X+LXY3cIn6THZUBqRBjeAvF+CWE2i3+eKcv2bzsCsnRsBYL8Qrqzp1dfs6HsVcSjfKt2RcrtUElw=="
}, },
"make-error": { "make-error": {
"version": "1.3.4", "version": "1.3.4",
@ -1005,9 +1005,9 @@
} }
}, },
"tslint-config-prettier": { "tslint-config-prettier": {
"version": "1.15.0", "version": "1.16.0",
"resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.15.0.tgz", "resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.16.0.tgz",
"integrity": "sha512-06CgrHJxJmNYVgsmeMoa1KXzQRoOdvfkqnJth6XUkNeOz707qxN0WfxfhYwhL5kXHHbYJRby2bqAPKwThlZPhw==", "integrity": "sha512-zu6RAcpBtqdvhT6KpBh9kRPYATjOf9BnRi718kNqVKFjEgSE4rFrPprFju1YJrkOa3RbtbWI1ZSuLd2NBX1MDw==",
"dev": true "dev": true
}, },
"tsutils": { "tsutils": {

View File

@ -1,7 +1,7 @@
{ {
"name": "@pushrocks/smarttime", "name": "@pushrocks/smarttime",
"private": false, "private": false,
"version": "3.0.2", "version": "3.0.5",
"description": "handle timeformats in smart ways", "description": "handle timeformats in smart ways",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
@ -16,13 +16,13 @@
"@gitzone/tsrun": "^1.1.13", "@gitzone/tsrun": "^1.1.13",
"@gitzone/tstest": "^1.0.15", "@gitzone/tstest": "^1.0.15",
"@pushrocks/tapbundle": "^3.0.7", "@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.12.0", "@types/node": "^10.12.10",
"tslint": "^5.11.0", "tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.16.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartpromise": "^2.0.5", "@pushrocks/smartpromise": "^2.0.5",
"@types/luxon": "^1.4.0", "@types/luxon": "^1.4.1",
"luxon": "^1.4.3" "luxon": "^1.8.0"
} }
} }

View File

@ -8,8 +8,12 @@ tap.test('should create a valid JavaScript Date from European TimeStamp', async
}); });
tap.test('should create a date and time with European Format', async () => { tap.test('should create a date and time with European Format', async () => {
const extendedDate = smarttime.ExtendedDate.fromEuropeanDateAndTime('9.8.2018', '08:00:00', 'Europe/Berlin'); const extendedDate = smarttime.ExtendedDate.fromEuropeanDateAndTime(
'9.8.2018',
'08:00:00',
'Europe/Berlin'
);
console.log(extendedDate); console.log(extendedDate);
}) });
tap.start(); tap.start();

View File

@ -15,4 +15,12 @@ tap.test('should start timer', async () => {
await testTimer.completed; await testTimer.completed;
}); });
tap.test('should reset a timer', async () => {
testTimer.reset();
testTimer.start();
testTimer.reset();
testTimer.start();
await testTimer.completed;
});
tap.start(); tap.start();

View File

@ -24,13 +24,12 @@ export class ExtendedDate extends Date {
const sliceDate = (dateString: string) => { const sliceDate = (dateString: string) => {
return `0${dateString}`.slice(-2); return `0${dateString}`.slice(-2);
}; };
const dateTimeString = `${dateArray[3]}-${sliceDate(dateArray[2])}-${sliceDate(dateArray[1])}T${timeArg}`; const dateTimeString = `${dateArray[3]}-${sliceDate(dateArray[2])}-${sliceDate(
const luxonDate = plugins.luxon.DateTime.fromISO( dateArray[1]
dateTimeString, )}T${timeArg}`;
{ const luxonDate = plugins.luxon.DateTime.fromISO(dateTimeString, {
zone: zoneArg zone: zoneArg
} });
);
const unixMilli = luxonDate.toMillis(); const unixMilli = luxonDate.toMillis();
return new ExtendedDate(unixMilli); return new ExtendedDate(unixMilli);
} }

View File

@ -61,8 +61,11 @@ export class Timer {
} }
public pause() { public pause() {
clearTimeout(this.currentTimeout); if (this.startedAt) {
this.pausedAt = TimeStamp.fromTimeStamp(this.startedAt); clearTimeout(this.currentTimeout);
this.currentTimeout = null;
this.pausedAt = TimeStamp.fromTimeStamp(this.startedAt);
}
} }
public resume() { public resume() {
@ -70,6 +73,14 @@ export class Timer {
this.currentTimeout = setTimeout(() => { this.currentTimeout = setTimeout(() => {
this.completedDeferred.resolve(); this.completedDeferred.resolve();
}, this.timeLeft); }, this.timeLeft);
} else {
throw new Error('timer has NOT been started before. Please use .start() instead');
} }
} }
public reset() {
this.pause();
this.startedAt = null;
this.pausedAt = null;
}
} }

View File

@ -1,6 +1,17 @@
{ {
"extends": [ "extends": ["tslint:latest", "tslint-config-prettier"],
"tslint:latest", "rules": {
"tslint-config-prettier" "semicolon": [true, "always"],
] "no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
} }