Skip to content

Commit 0fd67e6

Browse files
committed
fix: loosen input date type
1 parent ed9fd1b commit 0fd67e6

File tree

5 files changed

+10
-27
lines changed

5 files changed

+10
-27
lines changed

lib/src/timeago.clock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { Injectable } from '@angular/core';
22
import { Observable, of, empty, timer } from 'rxjs';
33
import { expand, skip } from 'rxjs/operators';
4-
import { MINUTE, HOUR, DAY, WEEK, MONTH, YEAR } from './util';
4+
import { MINUTE, HOUR, DAY } from './util';
55

66
export abstract class TimeagoClock {
77
abstract tick(then: number): Observable<any>;
88
}
99

1010
@Injectable()
1111
export class TimeagoDefaultClock extends TimeagoClock {
12-
tick(then: number): Observable<number> {
12+
tick(then: number): Observable<any> {
1313
return of(0)
1414
.pipe(
1515
expand(() => {

lib/src/timeago.directive.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
import {
2-
Directive,
3-
Input,
4-
ElementRef,
5-
Optional,
6-
SimpleChanges,
7-
OnChanges,
8-
OnDestroy,
9-
ChangeDetectorRef
10-
} from '@angular/core';
1+
import { Directive, Input, ElementRef, Optional, OnChanges, OnDestroy, ChangeDetectorRef } from '@angular/core';
112
import { Subscription, Subject } from 'rxjs';
123
import { filter } from 'rxjs/operators';
134
import { TimeagoClock } from './timeago.clock';
@@ -33,10 +24,10 @@ export class TimeagoDirective implements OnChanges, OnDestroy {
3324

3425
/** The Date to display. An actual Date object or something that can be fed to new Date. */
3526
@Input()
36-
get date(): number {
27+
get date(): any {
3728
return this._date;
3829
}
39-
set date(date: number) {
30+
set date(date: any) {
4031
this._date = dateParser(date).valueOf();
4132
if (this._date) {
4233
if (this.clockSubscription) {
@@ -76,7 +67,7 @@ export class TimeagoDirective implements OnChanges, OnDestroy {
7667
});
7768
}
7869

79-
ngOnChanges(changes: SimpleChanges) {
70+
ngOnChanges() {
8071
this.stateChanges.next();
8172
}
8273

lib/src/timeago.formatter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable, Optional } from '@angular/core';
1+
import { Injectable } from '@angular/core';
22
import { TimeagoIntl } from './timeago.intl';
33
import { MINUTE, HOUR, DAY, WEEK, MONTH, YEAR } from './util';
44

lib/src/timeago.module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { NgModule, ModuleWithProviders, Provider } from '@angular/core';
22
import { TimeagoDirective } from './timeago.directive';
33
import { TimeagoPipe } from './timeago.pipe';
4-
import { TimeagoIntl } from './timeago.intl';
54
import { TimeagoClock, TimeagoDefaultClock } from './timeago.clock';
65
import { TimeagoFormatter, TimeagoDefaultFormatter } from './timeago.formatter';
76

lib/src/timeago.pipe.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
Injectable,
3-
OnDestroy,
4-
Pipe,
5-
PipeTransform,
6-
Optional,
7-
ChangeDetectorRef
8-
} from '@angular/core';
1+
import { Injectable, OnDestroy, Pipe, PipeTransform, Optional, ChangeDetectorRef } from '@angular/core';
92
import { Subscription, Subject } from 'rxjs';
103
import { TimeagoClock } from './timeago.clock';
114
import { TimeagoFormatter } from './timeago.formatter';
@@ -36,7 +29,7 @@ export class TimeagoPipe implements PipeTransform, OnDestroy {
3629

3730
constructor(@Optional() intl: TimeagoIntl,
3831
cd: ChangeDetectorRef,
39-
private formatter: TimeagoFormatter,
32+
formatter: TimeagoFormatter,
4033
private clock: TimeagoClock) {
4134
if (intl) {
4235
this.intlSubscription = intl.changes.subscribe(() => this.stateChanges.next());
@@ -47,7 +40,7 @@ export class TimeagoPipe implements PipeTransform, OnDestroy {
4740
});
4841
}
4942

50-
transform(date: number, ...args: any[]) {
43+
transform(date: any, ...args: any[]) {
5144
const _date = dateParser(date).valueOf();
5245
let _live: boolean;
5346

0 commit comments

Comments
 (0)