forked from urish/ngx-moment
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
34 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
/* ngx-moment (c) 2015, 2016 Uri Shaked / MIT Licence */ | ||
|
||
import {Pipe, ChangeDetectorRef, PipeTransform} from '@angular/core'; | ||
import {Pipe, PipeTransform} from '@angular/core'; | ||
import * as moment from 'moment'; | ||
|
||
const momentConstructor = moment; | ||
|
||
@Pipe({ name: 'amAdd' }) | ||
export class AddPipe implements PipeTransform { | ||
transform(value: any, amount: moment.DurationInputArg1, unit?: moment.DurationInputArg2): any { | ||
if (typeof amount === 'undefined' || (typeof amount === 'number' && typeof unit === 'undefined')) { | ||
throw new Error('AddPipe: missing required arguments'); | ||
} | ||
return moment(value).add(amount, unit); | ||
return momentConstructor(value).add(amount, unit); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import * as moment from 'moment'; | ||
|
||
// under systemjs, moment is actually exported as the default export, so we account for that | ||
const momentConstructor: (value?: any) => moment.Moment = (<any>moment).default || moment; | ||
const momentConstructor = moment; | ||
|
||
@Pipe({ name: 'amLocal' }) | ||
export class LocalTimePipe implements PipeTransform { | ||
transform(value: Date | moment.Moment | string | number): moment.Moment { | ||
return moment(value).local(); | ||
return momentConstructor(value).local(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import * as moment from 'moment'; | ||
|
||
// under systemjs, moment is actually exported as the default export, so we account for that | ||
const momentConstructor: (value?: any) => moment.Moment = (<any>moment).default || moment; | ||
const momentConstructor = moment; | ||
|
||
@Pipe({ name: 'amParse' }) | ||
export class ParsePipe implements PipeTransform { | ||
transform(value: string, format: string): moment.Moment { | ||
return moment(value, format); | ||
return momentConstructor(value, format); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
/* ngx-moment (c) 2015, 2016 Uri Shaked / MIT Licence */ | ||
|
||
import {Pipe, ChangeDetectorRef, PipeTransform} from '@angular/core'; | ||
import {Pipe, PipeTransform} from '@angular/core'; | ||
import * as moment from 'moment'; | ||
|
||
const momentConstructor = moment; | ||
|
||
@Pipe({ name: 'amSubtract' }) | ||
export class SubtractPipe implements PipeTransform { | ||
transform(value: any, amount: moment.DurationInputArg1, unit?: moment.DurationInputArg2): any { | ||
if (typeof amount === 'undefined' || (typeof amount === 'number' && typeof unit === 'undefined')) { | ||
throw new Error('SubtractPipe: missing required arguments'); | ||
} | ||
return moment(value).subtract(amount, unit); | ||
return momentConstructor(value).subtract(amount, unit); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import * as moment from 'moment'; | ||
|
||
// under systemjs, moment is actually exported as the default export, so we account for that | ||
const momentConstructor: (value?: any) => moment.Moment = (<any>moment).default || moment; | ||
const momentConstructor = moment; | ||
|
||
@Pipe({ name: 'amUtc' }) | ||
export class UtcPipe implements PipeTransform { | ||
transform(value: Date | moment.Moment | string | number): moment.Moment { | ||
return moment(value).utc(); | ||
return momentConstructor(value).utc(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters