Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
6d8e39f11b | |||
cff5b5a7f4 | |||
f6be9b71f1 | |||
9c2d584170 | |||
10bff069c1 | |||
8f6272eca4 | |||
f02df7789c | |||
d720b8b084 |
@ -37,18 +37,6 @@ snyk:
|
|||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
testLEGACY:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install legacy
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
testLTS:
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
@ -135,13 +123,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
|
|
||||||
|
@ -2,5 +2,15 @@
|
|||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "smarttime",
|
||||||
|
"shortDescription": "handle time in smart ways",
|
||||||
|
"npmPackagename": "@pushrocks/smarttime",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
1010
package-lock.json
generated
1010
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smarttime",
|
"name": "@pushrocks/smarttime",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "3.0.2",
|
"version": "3.0.6",
|
||||||
"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",
|
||||||
@ -12,17 +12,19 @@
|
|||||||
"build": "(tsbuild)"
|
"build": "(tsbuild)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
"@gitzone/tsbuild": "^2.1.8",
|
||||||
"@gitzone/tsrun": "^1.1.13",
|
"@gitzone/tsrun": "^1.2.5",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.20",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^3.0.7",
|
||||||
"@types/node": "^10.12.0",
|
"@types/node": "^11.13.2",
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^5.15.0",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartpromise": "^2.0.5",
|
"@pushrocks/smartpromise": "^3.0.2",
|
||||||
"@types/luxon": "^1.4.0",
|
"@types/cron": "^1.7.0",
|
||||||
"luxon": "^1.4.3"
|
"@types/luxon": "^1.12.0",
|
||||||
|
"cron": "^1.7.0",
|
||||||
|
"luxon": "^1.12.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
36
readme.md
36
readme.md
@ -1,24 +1,20 @@
|
|||||||
# @pushrocks/smarttime
|
# @pushrocks/smarttime
|
||||||
|
handle time in smart ways
|
||||||
|
|
||||||
handle timeformats in smart ways
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smarttime)
|
||||||
## Availabililty
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smarttime)
|
||||||
|
* [github.com (source mirror)](https://github.com/pushrocks/smarttime)
|
||||||
[](https://www.npmjs.com/package/smarttime)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smarttime/)
|
||||||
[](https://GitLab.com/pushrocks/smarttime)
|
|
||||||
[](https://github.com/pushrocks/smarttime)
|
|
||||||
[](https://pushrocks.gitlab.io/smarttime/)
|
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
[](https://gitlab.com/pushrocks/smarttime/commits/master)
|
||||||
[](https://GitLab.com/pushrocks/smarttime/commits/master)
|
[](https://gitlab.com/pushrocks/smarttime/commits/master)
|
||||||
[](https://GitLab.com/pushrocks/smarttime/commits/master)
|
[](https://www.npmjs.com/package/@pushrocks/smarttime)
|
||||||
[](https://www.npmjs.com/package/smarttime)
|
[](https://snyk.io/test/npm/@pushrocks/smarttime)
|
||||||
[](https://david-dm.org/pushrocks/smarttime)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://www.bithound.io/github/pushrocks/smarttime/master/dependencies/npm)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://www.bithound.io/github/pushrocks/smarttime)
|
[](https://prettier.io/)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -35,9 +31,9 @@ import { ExtendedDate } from '@pushrocks/smarttime'
|
|||||||
const myDate: Date = ExtendedDate.fromEuropeanDate('8.6.2018')
|
const myDate: Date = ExtendedDate.fromEuropeanDate('8.6.2018')
|
||||||
```
|
```
|
||||||
|
|
||||||
For further information read the linked docs at the top of this README.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
[](https://push.rocks)
|
[](https://maintainedby.lossless.com)
|
||||||
|
11
test/test.cronmanager.ts
Normal file
11
test/test.cronmanager.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
|
|
||||||
|
import * as smarttime from '../ts/index';
|
||||||
|
|
||||||
|
let testCronManager: smarttime.CronManager;
|
||||||
|
|
||||||
|
tap.test('should create a valid instance of cronmanager', async () => {
|
||||||
|
testCronManager = new smarttime.CronManager();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
@ -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();
|
||||||
|
@ -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();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import * as plugins from './smarttime.plugins';
|
import * as plugins from './smarttime.plugins';
|
||||||
|
|
||||||
|
export * from './smarttime.classes.cronmanager';
|
||||||
export * from './smarttime.classes.date';
|
export * from './smarttime.classes.date';
|
||||||
export * from './smarttime.classes.hrtmeasurement';
|
export * from './smarttime.classes.hrtmeasurement';
|
||||||
export * from './smarttime.classes.timer';
|
export * from './smarttime.classes.timer';
|
||||||
|
3
ts/smarttime.classes.cronmanager.ts
Normal file
3
ts/smarttime.classes.cronmanager.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import * as plugins from './smarttime.plugins';
|
||||||
|
|
||||||
|
export class CronManager {}
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,11 @@ export class TimeStamp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a boolean for wether a timestamp is younger
|
||||||
|
* @param TimeStampArg
|
||||||
|
* @param tresholdTimeArg
|
||||||
|
*/
|
||||||
public isYoungerThanOtherTimeStamp(TimeStampArg: TimeStamp, tresholdTimeArg: number = 0) {
|
public isYoungerThanOtherTimeStamp(TimeStampArg: TimeStamp, tresholdTimeArg: number = 0) {
|
||||||
if (this.milliSeconds > TimeStampArg.milliSeconds + tresholdTimeArg) {
|
if (this.milliSeconds > TimeStampArg.milliSeconds + tresholdTimeArg) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -5,5 +5,6 @@ export { smartpromise };
|
|||||||
|
|
||||||
// third parties
|
// third parties
|
||||||
import * as luxon from 'luxon';
|
import * as luxon from 'luxon';
|
||||||
|
import * as cron from 'cron';
|
||||||
|
|
||||||
export { luxon };
|
export { luxon, cron };
|
||||||
|
19
tslint.json
19
tslint.json
@ -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"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user