Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/component/AttributionComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,8 @@ export class AttributionComponent extends Component<IComponentConfiguration> {
const imageBy: string = compact ? `${username}` : `image by ${username}`;
const imageByContent: vd.VNode = vd.h("div.AttributionUsername", { textContent: imageBy }, []);

const date: string[] = new Date(capturedAt).toDateString().split(" ");
const formatted: string = (date.length > 3 ?
compact ?
[date[3]] :
[date[1], date[2] + ",", date[3]] :
date).join(" ");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, the current implementation looks a bit overly complex to me or has dead code. Since this will always be true:

new Date(capturedAt).toDateString().split(" ").length > 3

Unless, Date.toDateString() is JavaScript runtime implementation specific, and thus behaves differently on different browsers. But, I am not aware of that.

const date: Date = new Date(capturedAt);
const formatted: string = compact ? date.toLocaleDateString() : date.toLocaleString();

const dateContent: vd.VNode = vd.h("div.AttributionDate", { textContent: formatted }, []);

Expand All @@ -80,7 +76,7 @@ export class AttributionComponent extends Component<IComponentConfiguration> {

return vd.h("div.AttributionContainer" + compactClass, {}, [mapillaryLink, imageLink]);
}
}
}

ComponentService.register(AttributionComponent);
export default AttributionComponent;