-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: support options arguments (#47)
- Loading branch information
Showing
23 changed files
with
66 additions
and
76 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
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/formatting/date-time-to-format.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DateTime } from 'luxon'; | ||
import { DateTime, LocaleOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'dateTimeToFormat' | ||
}) | ||
export class DateTimeToFormatPipe implements PipeTransform { | ||
transform <T extends DateTime | null | undefined>(value: T, format: string) { | ||
return (value == null ? null : value.toFormat(format)) as T extends DateTime ? string : null; | ||
transform <T extends DateTime | null | undefined>(value: T, format: string, opts?: LocaleOptions) { | ||
return (value == null ? null : value.toFormat(format, opts)) as T extends DateTime ? string : null; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/formatting/date-time-to-iso-date.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DateTime } from 'luxon'; | ||
import { DateTime, ToISODateOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'dateTimeToIsoDate' | ||
}) | ||
export class DateTimeToIsoDatePipe implements PipeTransform { | ||
transform <T extends DateTime | null | undefined>(value: T) { | ||
return (value == null ? null : value.toISODate()) as T extends DateTime ? string : null; | ||
transform <T extends DateTime | null | undefined>(value: T, opts?: ToISODateOptions) { | ||
return (value == null ? null : value.toISODate(opts)) as T extends DateTime ? string : null; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/formatting/date-time-to-iso-time.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DateTime } from 'luxon'; | ||
import { DateTime, ToISOTimeOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'dateTimeToIsoTime' | ||
}) | ||
export class DateTimeToIsoTimePipe implements PipeTransform { | ||
transform <T extends DateTime | null | undefined>(value: T) { | ||
return (value == null ? null : value.toISOTime()) as T extends DateTime ? string : null; | ||
transform <T extends DateTime | null | undefined>(value: T, opts?: ToISOTimeOptions) { | ||
return (value == null ? null : value.toISOTime(opts)) as T extends DateTime ? string : null; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/formatting/date-time-to-iso.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DateTime } from 'luxon'; | ||
import { DateTime, ToISOTimeOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'dateTimeToIso' | ||
}) | ||
export class DateTimeToIsoPipe implements PipeTransform { | ||
transform <T extends DateTime | null | undefined>(value: T) { | ||
return (value == null ? null : value.toISO()) as T extends DateTime ? string : null; | ||
transform <T extends DateTime | null | undefined>(value: T, opts?: ToISOTimeOptions) { | ||
return (value == null ? null : value.toISO(opts)) as T extends DateTime ? string : null; | ||
} | ||
} |
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
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/formatting/date-time-to-sql.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DateTime } from 'luxon'; | ||
import { DateTime, ToSQLOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'dateTimeToSql' | ||
}) | ||
export class DateTimeToSqlPipe implements PipeTransform { | ||
transform <T extends DateTime | null | undefined>(value: T) { | ||
return (value == null ? null : value.toSQL()) as T extends DateTime ? string : null; | ||
transform <T extends DateTime | null | undefined>(value: T, opts?: ToSQLOptions) { | ||
return (value == null ? null : value.toSQL(opts)) as T extends DateTime ? string : null; | ||
} | ||
} |
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
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/formatting/duration-to-human.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { Duration } from 'luxon'; | ||
import { Duration, ToHumanDurationOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'durationToHuman' | ||
}) | ||
export class DurationToHumanPipe implements PipeTransform { | ||
transform <T extends Duration | null | undefined>(value: T) { | ||
return (value == null ? null : value.toHuman()) as T extends Duration ? string : null; | ||
transform <T extends Duration | null | undefined>(value: T, opts?: ToHumanDurationOptions) { | ||
return (value == null ? null : value.toHuman(opts)) as T extends Duration ? string : null; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/formatting/duration-to-iso-time.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { Duration } from 'luxon'; | ||
import { Duration, ToISOTimeDurationOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'durationToIsoTime' | ||
}) | ||
export class DurationToIsoTimePipe implements PipeTransform { | ||
transform <T extends Duration | null | undefined>(value: T) { | ||
return (value == null ? null : value.toISOTime()) as T extends Duration ? string : null; | ||
transform <T extends Duration | null | undefined>(value: T, opts?: ToISOTimeDurationOptions) { | ||
return (value == null ? null : value.toISOTime(opts)) as T extends Duration ? string : null; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/parsing/date-time-from-format.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DateTime } from 'luxon'; | ||
import { DateTime, DateTimeOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'dateTimeFromFormat' | ||
}) | ||
export class DateTimeFromFormatPipe implements PipeTransform { | ||
transform <T extends string | null | undefined>(value: T, format: string) { | ||
return (value == null ? null : DateTime.fromFormat(value as string, format)) as T extends string ? DateTime : null; | ||
transform <T extends string | null | undefined>(value: T, format: string, opts?: DateTimeOptions) { | ||
return (value == null ? null : DateTime.fromFormat(value as string, format, opts)) as T extends string ? DateTime : null; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/parsing/date-time-from-http.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DateTime } from 'luxon'; | ||
import { DateTime, DateTimeOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'dateTimeFromHttp' | ||
}) | ||
export class DateTimeFromHttpPipe implements PipeTransform { | ||
transform <T extends string | null | undefined>(value: T) { | ||
return (value == null ? null : DateTime.fromHTTP(value as string)) as T extends string ? DateTime : null; | ||
transform <T extends string | null | undefined>(value: T, opts?: DateTimeOptions) { | ||
return (value == null ? null : DateTime.fromHTTP(value as string, opts)) as T extends string ? DateTime : null; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/parsing/date-time-from-iso.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DateTime } from 'luxon'; | ||
import { DateTime, DateTimeOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'dateTimeFromIso' | ||
}) | ||
export class DateTimeFromIsoPipe implements PipeTransform { | ||
transform <T extends string | null | undefined>(value: T) { | ||
return (value == null ? null : DateTime.fromISO(value as string)) as T extends string ? DateTime : null; | ||
transform <T extends string | null | undefined>(value: T, opts?: DateTimeOptions) { | ||
return (value == null ? null : DateTime.fromISO(value as string, opts)) as T extends string ? DateTime : null; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/parsing/date-time-from-js-date.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DateTime } from 'luxon'; | ||
import { DateTime, Zone } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'dateTimeFromJsDate' | ||
}) | ||
export class DateTimeFromJsDatePipe implements PipeTransform { | ||
transform <T extends Date | null | undefined>(value: T) { | ||
return (value == null ? null : DateTime.fromJSDate(value as Date)) as T extends Date ? DateTime : null; | ||
transform <T extends Date | null | undefined>(value: T, opts?: { zone?: string | Zone }) { | ||
return (value == null ? null : DateTime.fromJSDate(value as Date, opts)) as T extends Date ? DateTime : null; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/parsing/date-time-from-milliseconds.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DateTime } from 'luxon'; | ||
import { DateTime, DateTimeJSOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'dateTimeFromMilliseconds' | ||
}) | ||
export class DateTimeFromMillisecondsPipe implements PipeTransform { | ||
transform <T extends number | null | undefined>(value: T) { | ||
return (value == null ? null : DateTime.fromMillis(value as number)) as T extends number ? DateTime : null; | ||
transform <T extends number | null | undefined>(value: T, opts?: DateTimeJSOptions) { | ||
return (value == null ? null : DateTime.fromMillis(value as number, opts)) as T extends number ? DateTime : null; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/parsing/date-time-from-rfc-2822.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DateTime } from 'luxon'; | ||
import { DateTime, DateTimeOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'dateTimeFromRfc2822' | ||
}) | ||
export class DateTimeFromRfc2822Pipe implements PipeTransform { | ||
transform <T extends string | null | undefined>(value: T) { | ||
return (value == null ? null : DateTime.fromRFC2822(value as string)) as T extends string ? DateTime : null; | ||
transform <T extends string | null | undefined>(value: T, opts?: DateTimeOptions) { | ||
return (value == null ? null : DateTime.fromRFC2822(value as string, opts)) as T extends string ? DateTime : null; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/parsing/date-time-from-sql.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DateTime } from 'luxon'; | ||
import { DateTime, DateTimeOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'dateTimeFromSql' | ||
}) | ||
export class DateTimeFromSqlPipe implements PipeTransform { | ||
transform <T extends string | null | undefined>(value: T) { | ||
return (value == null ? null : DateTime.fromSQL(value as string)) as T extends string ? DateTime : null; | ||
transform <T extends string | null | undefined>(value: T, opts?: DateTimeOptions) { | ||
return (value == null ? null : DateTime.fromSQL(value as string, opts)) as T extends string ? DateTime : null; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/parsing/duration-from-iso-time.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { Duration } from 'luxon'; | ||
import { Duration, DurationOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'durationFromIsoTime' | ||
}) | ||
export class DurationFromIsoTimePipe implements PipeTransform { | ||
transform <T extends string | null | undefined>(value: T) { | ||
return (value == null ? null : Duration.fromISOTime(value as string)) as T extends string ? Duration : null; | ||
transform <T extends string | null | undefined>(value: T, opts?: DurationOptions) { | ||
return (value == null ? null : Duration.fromISOTime(value as string, opts)) as T extends string ? Duration : null; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/parsing/duration-from-iso.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { Duration } from 'luxon'; | ||
import { Duration, DurationOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'durationFromIso' | ||
}) | ||
export class DurationFromIsoPipe implements PipeTransform { | ||
transform <T extends string | null | undefined>(value: T) { | ||
return (value == null ? null : Duration.fromISO(value as string)) as T extends string ? Duration : null; | ||
transform <T extends string | null | undefined>(value: T, opts?: DurationOptions) { | ||
return (value == null ? null : Duration.fromISO(value as string, opts)) as T extends string ? Duration : null; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/parsing/duration-from-milliseconds.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { Duration } from 'luxon'; | ||
import { Duration, DurationOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'durationFromMilliseconds' | ||
}) | ||
export class DurationFromMillisecondsPipe implements PipeTransform { | ||
transform <T extends number | null | undefined>(value: T) { | ||
return (value == null ? null : Duration.fromMillis(value as number)) as T extends number ? Duration : null; | ||
transform <T extends number | null | undefined>(value: T, opts?: DurationOptions) { | ||
return (value == null ? null : Duration.fromMillis(value as number, opts)) as T extends number ? Duration : null; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
projects/luxon-angular/src/lib/zones/date-time-to-utc.pipe.ts
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,11 +1,11 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import { DateTime } from 'luxon'; | ||
import { DateTime, ZoneOptions } from 'luxon'; | ||
|
||
@Pipe({ | ||
name: 'dateTimeToUtc' | ||
}) | ||
export class DateTimeToUtcPipe implements PipeTransform { | ||
transform <T extends DateTime | null | undefined>(value: T) { | ||
return (value == null ? null : value.toUTC()) as T extends DateTime ? DateTime : null; | ||
transform <T extends DateTime | null | undefined>(value: T, offset?: number, opts?: ZoneOptions) { | ||
return (value == null ? null : value.toUTC(offset, opts)) as T extends DateTime ? DateTime : null; | ||
} | ||
} |