Skip to content

Commit

Permalink
fix: shows events/event dates as-is
Browse files Browse the repository at this point in the history
Gatsby converts stored date to UTC cases the reported
dates shifts. This patch is to shows stored date as-is and
format date in UI side which is known as a workaround.

Fixes: aws-amplify#17
Refs: gatsbyjs/gatsby#11832 (comment)
  • Loading branch information
watilde committed Oct 23, 2020
1 parent 4125d15 commit c7ee637
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/graphql-fragments.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const SharedBetweenPostsAndEventsFragment = graphql`
fields {
key
slug
date(formatString: "MMMM D, YYYY")
date
}
frontmatter {
href
Expand Down
3 changes: 2 additions & 1 deletion src/templates/Event.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {graphql, Link} from 'gatsby';
import moment from 'moment';
import {track, extract, mapNodeToProps} from '~/utilities';
import Img from 'gatsby-image';
import {Text, Meta, Layout, Nav, Button} from '~/components';
Expand Down Expand Up @@ -182,7 +183,7 @@ export default props => {
<div className='details'>
<Text h2>{title}</Text>
<div className='logistics'>
<Text h4 children={date} />
<Text h4 children={moment(date).format(`MMMM D, YYYY`)} />
<Text h4 children=' in ' />
<Text h4 children={join(', ', [city, country])} />
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/utilities/groupEventEdges.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {reduce, assoc, invertObj} from 'ramda';
import moment from 'moment';
import * as extract from './extract';

export const monthNameByIndex = [
Expand Down Expand Up @@ -27,5 +28,6 @@ export default reduce((accumulator, current) => {
const monthIndex = date.getMonth();
const month = monthNameByIndex[monthIndex];
const key = `${month} ${year}`;
current.node.fields.date = moment(stringifiedDate).format(`MMMM D, YYYY`);
return assoc(key, [...(accumulator[key] || []), current], accumulator);
}, {});

0 comments on commit c7ee637

Please sign in to comment.