Skip to content

Commit

Permalink
Add year to route date when not current year (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalkrishnads authored Jun 22, 2024
1 parent 112d624 commit f4ea601
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/components/Dashboard/DriveListItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ const DriveListItem = (props) => {
);

const small = windowWidth < 580;
const startTime = dayjs(drive.start_time_utc_millis).format('HH:mm');
const startDate = dayjs(drive.start_time_utc_millis).format(small ? 'ddd, MMM D' : 'dddd, MMM D');
const dateFormat = small ? 'ddd, MMM D' : 'dddd, MMM D';
const startDateObj = dayjs(drive.start_time_utc_millis);
const startTime = startDateObj.format('HH:mm');
const startDate = startDateObj.format(dayjs().year() === startDateObj.year() ? dateFormat : `${dateFormat}, YYYY`);
const endTime = dayjs(drive.end_time_utc_millis).format('HH:mm');
const duration = formatDriveDuration(drive.duration);

Expand Down
5 changes: 3 additions & 2 deletions src/components/DriveView/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ class DriveView extends Component {

// FIXME: end time not always same day as start time
const start = currentRoute.start_time_utc_millis + zoom.start;
const startDay = dayjs(start).format('dddd');
const startTime = dayjs(start).format('MMM D @ HH:mm');
const startDateObj = dayjs(start);
const startDay = startDateObj.format('dddd');
const startTime = startDateObj.format(`MMM D${dayjs().year() === startDateObj.year() ? '' : ', YYYY'} @ HH:mm`);
const endTime = dayjs(start + (zoom.end - zoom.start)).format('HH:mm');

return (
Expand Down

0 comments on commit f4ea601

Please sign in to comment.