Skip to content

Commit c77d01a

Browse files
committed
fix(pat display time): Default to locale-formatted output.
Default to formatted output according to the current locale. This fixes a regression since 4.1.0 which came with the date picker's styled behavior but let display time output an ISO date instead of a formatted date when not output format was set.
1 parent 79dadc5 commit c77d01a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/pat/display-time/display-time.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default Base.extend({
4848
let out = "";
4949
if (datetime) {
5050
const date = Moment(datetime, this.options.format, this.options.strict);
51+
out = date;
5152
if (this.options.fromNow === true) {
5253
if (utils.is_iso_date(datetime)) {
5354
// date-only case.
@@ -71,8 +72,8 @@ export default Base.extend({
7172
// datetime case.
7273
out = date.fromNow(this.options.noSuffix);
7374
}
74-
} else {
75-
out = date.format(this.options.outputFormat || undefined);
75+
} else if (this.options.outputFormat) {
76+
out = date.format(this.options.outputFormat);
7677
}
7778
}
7879
this.el.textContent = out;

src/pat/display-time/display-time.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("pat-display-time tests", () => {
2424
Pattern.init(el);
2525
await utils.timeout(1); // wait a tick for async to settle.
2626

27-
expect(el.textContent).toBe("2021-04-22T03:00:00-07:00");
27+
expect(el.textContent).toBe("Thu Apr 22 2021 03:00:00 GMT-0700");
2828
});
2929

3030
it("Example setting the output format explicitly", async () => {

0 commit comments

Comments
 (0)