Skip to content

Commit 5a23147

Browse files
guguclaude
andcommitted
Fix datetime filter: use genuine UTC for presets, consistent time format
- Use toISOString() instead of format() with literal 'Z' suffix to produce correct UTC timestamps for preset intervals - Default time to '00:00:00' (with seconds) for format consistency - Remove redundant output() override inherited from base class Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c92967a commit 5a23147

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

frontend/src/app/components/ui-components/filter-fields/date-time/date-time.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe('DateTimeFilterComponent', () => {
124124
const fieldEvent = vi.spyOn(component.onFieldChange, 'emit');
125125
component.onDateChange();
126126

127-
expect(component.time).toEqual('00:00');
128-
expect(fieldEvent).toHaveBeenCalledWith('2021-08-26T00:00Z');
127+
expect(component.time).toEqual('00:00:00');
128+
expect(fieldEvent).toHaveBeenCalledWith('2021-08-26T00:00:00Z');
129129
});
130130
});

frontend/src/app/components/ui-components/filter-fields/date-time/date-time.component.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CommonModule } from '@angular/common';
2-
import { AfterViewInit, Component, ElementRef, Input, OnInit, output, ViewChild } from '@angular/core';
2+
import { AfterViewInit, Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
33
import { FormsModule } from '@angular/forms';
44
import { MatFormFieldModule } from '@angular/material/form-field';
55
import { MatInputModule } from '@angular/material/input';
@@ -17,8 +17,6 @@ export class DateTimeFilterComponent extends BaseFilterFieldComponent implements
1717
@Input() value: string;
1818
@ViewChild('inputElement') inputElement: ElementRef<HTMLInputElement>;
1919

20-
override readonly onFieldChange = output<any>();
21-
2220
public filterMode: string = 'last_day';
2321
public date: string;
2422
public time: string;
@@ -68,7 +66,7 @@ export class DateTimeFilterComponent extends BaseFilterFieldComponent implements
6866
}
6967

7068
onDateChange(): void {
71-
if (!this.time) this.time = '00:00';
69+
if (!this.time) this.time = '00:00:00';
7270
const datetime = `${this.date}T${this.time}Z`;
7371
this.onFieldChange.emit(datetime);
7472
this.onComparatorChange.emit(this.filterMode);
@@ -108,6 +106,6 @@ export class DateTimeFilterComponent extends BaseFilterFieldComponent implements
108106
targetDate = now;
109107
}
110108

111-
return format(targetDate, "yyyy-MM-dd'T'HH:mm:ss'Z'");
109+
return targetDate.toISOString().replace(/\.\d{3}Z$/, 'Z');
112110
}
113111
}

0 commit comments

Comments
 (0)