-
Notifications
You must be signed in to change notification settings - Fork 248
fix(DateFilter): fix a wrong type #579
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ class DateFilter { | |
'shortTime': 'h:mm a', | ||
}; | ||
|
||
Map<num, NumberFormat> nfs = new Map<num, NumberFormat>(); | ||
var dfs = <String, DateFormat>{}; | ||
|
||
/** | ||
* [date]: Date to format either as Date object, milliseconds | ||
|
@@ -52,13 +52,13 @@ class DateFilter { | |
if (date is String) date = DateTime.parse(date); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the main public service of this class is delivered through the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop the |
||
if (date is num) date = new DateTime.fromMillisecondsSinceEpoch(date); | ||
if (date is! DateTime) return date; | ||
var nf = nfs[format]; | ||
if (nf == null) { | ||
var df = dfs[format]; | ||
if (df == null) { | ||
if (MAP.containsKey(format)) { | ||
format = MAP[format]; | ||
} | ||
nf = new DateFormat(format); | ||
df = new DateFormat(format); | ||
} | ||
return nf.format(date); | ||
return df.format(date); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the purpose of
dfs
. It is empty and never assigned to. Given that this is an@NgFilter
class it will only be instantiated by the dependency injector and access to this instance will be limited to use via an AngularDart pipe. Hence, clients will not have access todfs
.If I were to guess a use for
dfs
it would be as a cache. In which case it should be populated with values just before line 61 after a value is obtained fordf
; i.e.,In this case
dfs
should be made private:_dfs
.