Fix date format in category service.
This commit is contained in:
parent
89fc42c47a
commit
1bd59cbbf8
@ -1,5 +1,7 @@
|
||||
// vim: set tw=80 ts=2 sw=2 sts=2:
|
||||
|
||||
import * as moment from 'moment';
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
|
||||
@ -13,14 +15,23 @@ export class CategoryService {
|
||||
private restangular: Restangular
|
||||
) {}
|
||||
|
||||
formatDate(date: Date|string) {
|
||||
if(date instanceof Date) {
|
||||
return moment(date).format('YYYY-MM-DD');
|
||||
}
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
query(id: number, minDate: Date = null, maxDate: Date = null): Observable<Category[]> {
|
||||
var dateRange: any;
|
||||
var dateRange: any = {};
|
||||
|
||||
if(minDate) {
|
||||
dateRange.begin = minDate;
|
||||
dateRange.begin = this.formatDate(minDate);
|
||||
}
|
||||
|
||||
if(maxDate) {
|
||||
dateRange.end = maxDate;
|
||||
dateRange.end = this.formatDate(maxDate);
|
||||
}
|
||||
|
||||
return this.restangular.one('account', id).getList('category', dateRange);
|
||||
|
Loading…
Reference in New Issue
Block a user