Compare commits

..

6 Commits

Author SHA1 Message Date
4a56527f7d 3.0.1 2018-10-21 12:12:45 +02:00
2a14d928a8 fix(date): now supports date and time 2018-10-21 12:12:44 +02:00
f161f71c4e 3.0.0 2018-10-17 01:42:36 +02:00
ed1f79caa4 BREAKING CHANGE(deps): remove moment and use luxon 2018-10-17 01:42:36 +02:00
539bbc1568 2.0.2 2018-07-13 00:03:08 +02:00
7d4bf05289 fix(dependencies): leaner dependencies 2018-07-13 00:03:08 +02:00
12 changed files with 921 additions and 191 deletions

View File

@ -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

View File

@ -1,8 +1,6 @@
{
"npmci": {
"npmGlobalTools": [
"npmts"
],
"npmGlobalTools": [],
"npmAccessLevel": "public"
}
}

998
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -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"
}
}

View File

@ -19,12 +19,13 @@ handle timeformats in smart ways
[![bitHound Code](https://www.bithound.io/github/pushrocks/smarttime/badges/code.svg)](https://www.bithound.io/github/pushrocks/smarttime)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](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
View 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();

View File

@ -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';

View File

@ -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

View File

@ -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';

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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 };