From 24be608434d9fbce88f88afb5fa030490b0a5ac5 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Thu, 1 Nov 2018 22:59:44 -0400 Subject: [PATCH] clean up --- src/app/app.module.ts | 2 - src/app/pipes/mastodon-time.pipe.spec.ts | 8 ---- src/app/pipes/mastodon-time.pipe.ts | 48 ------------------------ 3 files changed, 58 deletions(-) delete mode 100644 src/app/pipes/mastodon-time.pipe.spec.ts delete mode 100644 src/app/pipes/mastodon-time.pipe.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 0995eaa6..50e84682 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -40,7 +40,6 @@ import { ThreadComponent } from './components/stream/thread/thread.component'; import { HashtagComponent } from './components/stream/hashtag/hashtag.component'; import { StreamOverlayComponent } from './components/stream/stream-overlay/stream-overlay.component'; import { DatabindedTextComponent } from './components/stream/status/databinded-text/databinded-text.component'; -import { MastodonTimePipe } from './pipes/mastodon-time.pipe'; import { TimeAgoPipe } from './pipes/time-ago.pipe'; const routes: Routes = [ @@ -75,7 +74,6 @@ const routes: Routes = [ HashtagComponent, StreamOverlayComponent, DatabindedTextComponent, - MastodonTimePipe, TimeAgoPipe ], imports: [ diff --git a/src/app/pipes/mastodon-time.pipe.spec.ts b/src/app/pipes/mastodon-time.pipe.spec.ts deleted file mode 100644 index 312c4165..00000000 --- a/src/app/pipes/mastodon-time.pipe.spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { MastodonTimePipe } from './mastodon-time.pipe'; - -xdescribe('MastodonTimePipe', () => { -// it('create an instance', () => { -// const pipe = new MastodonTimePipe(); -// expect(pipe).toBeTruthy(); -// }); -}); diff --git a/src/app/pipes/mastodon-time.pipe.ts b/src/app/pipes/mastodon-time.pipe.ts deleted file mode 100644 index 44c7b90d..00000000 --- a/src/app/pipes/mastodon-time.pipe.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { Pipe, PipeTransform, Inject, LOCALE_ID } from '@angular/core'; -import { formatDate } from '@angular/common'; - -@Pipe({ - name: 'mastodontime', - pure: false -}) -export class MastodonTimePipe implements PipeTransform { - - constructor(@Inject(LOCALE_ID) private locale: string) { } - - // private cachedDict: { [id:string] : string } = {}; - // private cached: string; - // private resultCached: string; - - transform(value: string): string { - // if (value == this.cached && this.resultCached) { - // return this.resultCached; - // } - - // if(this.cachedDict[value]) { - // return this.cachedDict[value]; - // } - - const date = (new Date(value)).getTime(); - const now = Date.now(); - const timeDelta = (now - date) / (1000); - - if (timeDelta < 60) { - return `${timeDelta | 0}s`; - } else if (timeDelta < 60 * 60) { - return `${timeDelta / 60 | 0}m`; - } else if (timeDelta < 60 * 60 * 24) { - return `${timeDelta / (60 * 60) | 0}h`; - } else if (timeDelta < 60 * 60 * 24 * 31) { - return `${timeDelta / (60 * 60 * 24) | 0}d`; - } - - return formatDate(date, 'MM/dd', this.locale); - - // this.cachedDict[value] = formatDate(date, 'MM/dd', this.locale); - - // // this.cached = value; - // // this.resultCached = formatDate(date, 'MM/dd', this.locale); - - // return this.cachedDict[value]; - } -}