Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
4a56527f7d | |||
2a14d928a8 | |||
f161f71c4e | |||
ed1f79caa4 | |||
539bbc1568 | |||
7d4bf05289 |
@ -26,6 +26,7 @@ mirror:
|
||||
snyk:
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install -g snyk
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
@ -39,6 +40,7 @@ snyk:
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install legacy
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
@ -51,6 +53,7 @@ testLEGACY:
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
@ -62,6 +65,7 @@ testLTS:
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
@ -117,8 +121,10 @@ pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command npm install -g npmpage
|
||||
- npmci command npmpage
|
||||
- npmci command npm install -g typedoc typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
@ -128,3 +134,14 @@ pages:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
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
|
||||
|
@ -1,8 +1,6 @@
|
||||
{
|
||||
"npmci": {
|
||||
"npmGlobalTools": [
|
||||
"npmts"
|
||||
],
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
}
|
||||
}
|
998
package-lock.json
generated
998
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -1,24 +1,28 @@
|
||||
{
|
||||
"name": "@pushrocks/smarttime",
|
||||
"private": false,
|
||||
"version": "2.0.1",
|
||||
"version": "3.0.1",
|
||||
"description": "handle timeformats in smart ways",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tsrun ./test/test.ts)",
|
||||
"build": "(npmts)"
|
||||
"test": "(tstest ./test/)",
|
||||
"build": "(tsbuild)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsrun": "^1.0.5",
|
||||
"@types/node": "^9.4.7",
|
||||
"tapbundle": "^2.0.0"
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tsrun": "^1.1.13",
|
||||
"@gitzone/tstest": "^1.0.15",
|
||||
"@pushrocks/tapbundle": "^3.0.7",
|
||||
"@types/node": "^10.12.0",
|
||||
"tslint": "^5.11.0",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"moment": "^2.21.0",
|
||||
"smartdelay": "^1.0.4",
|
||||
"smartq": "^1.1.6"
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@types/luxon": "^1.4.0",
|
||||
"luxon": "^1.4.3"
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,13 @@ handle timeformats in smart ways
|
||||
[](https://www.bithound.io/github/pushrocks/smarttime)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
Smarttime offers smart ways to deal with time.
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
|
15
test/test.date.ts
Normal file
15
test/test.date.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
|
||||
import * as smarttime from '../ts/index';
|
||||
|
||||
tap.test('should create a valid JavaScript Date from European TimeStamp', async () => {
|
||||
const extendedDate = smarttime.ExtendedDate.fromEuropeanDate('10.10.2018');
|
||||
console.log(extendedDate);
|
||||
});
|
||||
|
||||
tap.test('should create a date and time with European Format', async () => {
|
||||
const extendedDate = smarttime.ExtendedDate.fromEuropeanDateAndTime('10.10.2018', '08:00:00', 'Europe/Berlin');
|
||||
console.log(extendedDate);
|
||||
})
|
||||
|
||||
tap.start();
|
@ -1,5 +1,5 @@
|
||||
// tslint:disable-next-line:no-implicit-dependencies
|
||||
import { expect, tap } from 'tapbundle';
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
|
||||
import { Timer } from '../ts/index';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// tslint:disable-next-line:no-implicit-dependencies
|
||||
import { expect, tap } from 'tapbundle';
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as smarttime from '../ts/index';
|
||||
|
||||
// Test TimeStamp class
|
||||
|
@ -1,8 +1,9 @@
|
||||
import * as plugins from './smarttime.plugins';
|
||||
|
||||
export * from './smarttime.classes.date';
|
||||
export * from './smarttime.classes.hrtmeasurement';
|
||||
export * from './smarttime.classes.timer';
|
||||
export * from './smarttime.classes.timestamp';
|
||||
export * from './smarttime.units';
|
||||
|
||||
export { moment } from './smarttime.plugins';
|
||||
export { luxon } from './smarttime.plugins';
|
||||
|
@ -1 +1,30 @@
|
||||
import * as plugins from './smarttime.plugins';
|
||||
|
||||
export type TAvailableZone = 'Europe/Berlin';
|
||||
|
||||
export class ExtendedDate extends Date {
|
||||
public static fromEuropeanDate(europeanDate: string) {
|
||||
const dateArray = /(.*)\.(.*)\.(.*)/.exec(europeanDate);
|
||||
const luxonDate = plugins.luxon.DateTime.utc(
|
||||
parseFloat(dateArray[3]), // year
|
||||
parseFloat(dateArray[2]), // month
|
||||
parseFloat(dateArray[1]) // day
|
||||
);
|
||||
const unixMilli = luxonDate.toMillis();
|
||||
return new ExtendedDate(unixMilli);
|
||||
}
|
||||
|
||||
/** */
|
||||
public static fromEuropeanDateAndTime(europeanDateArg: string, timeArg: string, zoneArg: TAvailableZone) {
|
||||
const dateArray = /(.*)\.(.*)\.(.*)/.exec(europeanDateArg);
|
||||
const luxonDate = plugins.luxon.DateTime.fromISO(`${dateArray[3]}-${dateArray[2]}-${dateArray[1]}T${timeArg}`, {
|
||||
zone: zoneArg
|
||||
});
|
||||
const unixMilli = luxonDate.toMillis();
|
||||
return new ExtendedDate(unixMilli);
|
||||
}
|
||||
|
||||
constructor(unixMilli: number) {
|
||||
super(unixMilli);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ export class Timer {
|
||||
private currentTimeout: NodeJS.Timer;
|
||||
|
||||
// a deferred triggeted when Timer has completed
|
||||
private completedDeferred = plugins.smartq.defer<void>();
|
||||
private completedDeferred = plugins.smartpromise.defer<void>();
|
||||
|
||||
constructor(timeInMillisecondsArg: number) {
|
||||
this.timeInMilliseconds = timeInMillisecondsArg;
|
||||
|
@ -1,4 +1,9 @@
|
||||
import * as moment from 'moment';
|
||||
import * as smartq from 'smartq';
|
||||
// @pushrocks scope
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
|
||||
export { moment, smartq };
|
||||
export { smartpromise };
|
||||
|
||||
// third parties
|
||||
import * as luxon from 'luxon';
|
||||
|
||||
export { luxon };
|
||||
|
Reference in New Issue
Block a user