@@ -30,6 +30,7 @@ import { PlatformService } from '../services/platform.service';
3030import { SettingsService } from '../services/settings.service' ;
3131import { SourcesService } from '../services/sources.service' ;
3232import { SettingsComponent } from '../settings/settings.component' ;
33+ import { formatDateAsDay , formatDateAsLong , formatDateRelative } from '../lib/date-utils' ;
3334
3435@Component ( {
3536 selector : 'app-feed' ,
@@ -51,6 +52,10 @@ export class FeedPage {
5152 public filter : string = '' ;
5253 public currentScrollOffset : number = 0 ;
5354
55+ public formatDateAsDay = formatDateAsDay ;
56+ public formatDateAsLong = formatDateAsLong ;
57+ public formatDateRelative = formatDateRelative ;
58+
5459 constructor ( public sourcesService : SourcesService , public platformService : PlatformService ,
5560 public bookmarkService : BookmarkService , public feedService : FeedService ,
5661 private modalController : ModalController , public elementRef : ElementRef ,
@@ -59,36 +64,6 @@ export class FeedPage {
5964 chevronUpOutline } ) ;
6065 }
6166
62- public formatDate ( dateStr : string | number , locale : string ) {
63- const date = new Date ( dateStr ) ;
64- const dateOptions : Intl . DateTimeFormatOptions = {
65- weekday : 'short' ,
66- month : 'short' ,
67- day : 'numeric'
68- } ;
69- return date . toLocaleDateString ( locale , dateOptions ) ;
70- }
71-
72- public formatDateAsDay ( dateStr : string | number , locale : string ) {
73- const date = new Date ( dateStr ) ;
74- const dateOptions : Intl . DateTimeFormatOptions = {
75- weekday : 'short'
76- } ;
77- return date . toLocaleDateString ( locale , dateOptions ) ;
78- }
79-
80- public formatDateAsLong ( dateStr : string | number , locale : string ) {
81- const date = new Date ( dateStr ) ;
82- const dateOptions : Intl . DateTimeFormatOptions = {
83- hour : 'numeric' ,
84- minute : 'numeric' ,
85- weekday : 'short' ,
86- month : 'short' ,
87- day : 'numeric'
88- } ;
89- return date . toLocaleDateString ( locale , dateOptions ) ;
90- }
91-
9267 public scrollToTop ( ) {
9368 this . mainFeed . scrollToTop ( 400 ) ;
9469 }
0 commit comments