Skip to content
This repository has been archived by the owner on Jul 12, 2021. It is now read-only.

Commit

Permalink
Revert UTC mode changes
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmeuli committed Apr 9, 2020
1 parent 097557f commit b55b8dd
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 19 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"@types/html-webpack-plugin": "^3.2.2",
"@types/jest": "^25.2.1",
"@types/license-checker-webpack-plugin": "^0.0.2",
"@types/moment-timezone": "^0.5.13",
"@types/webpack": "^4.41.10",
"@types/webpack-merge": "^4.1.5",
"@typescript-eslint/eslint-plugin": "^2.27.0",
Expand All @@ -114,6 +115,7 @@
"jest": "^25.3.0",
"license-checker-webpack-plugin": "^0.1.4",
"mockdate": "^2.0.3",
"moment-timezone": "^0.5.28",
"npm-run-all": "^4.1.3",
"prettier": "^1.18.2",
"sass": "^1.26.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Moment } from "moment";
import React, { ChangeEvent, PureComponent, ReactNode } from "react";

import TodayIcon from "../../../../assets/icons/today.svg";
import { createDate, parseDate } from "../../../../utils/dateFormat";
import { createDate } from "../../../../utils/dateFormat";
import { translations } from "../../../../utils/i18n";
import { iconProps } from "../../../../utils/icons";

Expand Down Expand Up @@ -78,7 +78,7 @@ export default class SearchBar extends PureComponent<Props, State> {
const { newSearchKey } = this.state;

const today = createDate();
const isToday = parseDate(dateSelected).isSame(today, "day");
const isToday = dateSelected.isSame(today, "day");

return (
<div className="view-selector">
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/files/import/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ export function parseJrnlJson(jsonStr: string): Entries {
entry: DiaryEntry;
} => {
const parsedEntryCast = parsedEntry as JrnlEntry;
const { date, title, body } = parsedEntryCast;
const indexDate = toIndexDate(date);
const { date: indexDate, title, body } = parsedEntryCast;

const entry = { dateUpdated: now, title: title.trim(), text: body.trim() };
return { indexDate, entry };
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/utils/dateFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const MONTH_YEAR_FORMAT = "MMMM YYYY"; // E.g. "January 2019"
* Creates a Moment object instance for the current date and time
*/
export function createDate(): Moment {
return moment.utc();
return moment();
}

/**
Expand All @@ -23,7 +23,7 @@ export function parseDate(
date: Date | Moment | string,
format?: MomentFormatSpecification,
): Moment {
return moment.utc(date, format);
return moment(date, format);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions test/import-export/files/jsonDayOne.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
},
"entries": [
{
"modifiedDate": "2019-01-01T00:00:00Z",
"modifiedDate": "2019-01-03T00:00:00-08:00",
"text": "# Diary Entry 1\n\nThis text is **bold** and _italic_.",
"creationDate": "2019-01-01T00:00:00Z"
"creationDate": "2019-01-01T00:00:00-08:00"
},
{
"modifiedDate": "2019-01-01T00:00:00Z",
"modifiedDate": "2019-01-03T00:00:00-08:00",
"text": "# Diary Entry 2\n\nHere's a bulleted list:\n\n- One\n- Two\n- Three\n\nAnd here's a numbered list:\n\n1. One\n2. Two\n3. Three",
"creationDate": "2019-01-02T00:00:00Z"
"creationDate": "2019-01-02T00:00:00-08:00"
}
]
}
6 changes: 3 additions & 3 deletions test/import-export/files/jsonMiniDiary.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
"metadata": {
"application": "Mini Diary",
"version": "v0.0.0",
"dateUpdated": "Tue Jan 01 2019 00:00:00 GMT+0000"
"dateUpdated": "Thu Jan 03 2019 00:00:00 GMT-0800"
},
"entries": {
"2019-01-01": {
"dateUpdated": "Tue Jan 01 2019 00:00:00 GMT+0000",
"dateUpdated": "Thu Jan 03 2019 00:00:00 GMT-0800",
"title": "Diary Entry 1",
"text": "This text is **bold** and _italic_."
},
"2019-01-02": {
"dateUpdated": "Tue Jan 01 2019 00:00:00 GMT+0000",
"dateUpdated": "Thu Jan 03 2019 00:00:00 GMT-0800",
"title": "Diary Entry 2",
"text": "Here's a bulleted list:\n\n- One\n- Two\n- Three\n\nAnd here's a numbered list:\n\n1. One\n2. Two\n3. Three"
}
Expand Down
8 changes: 4 additions & 4 deletions test/import-export/referenceData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
*/
export const referenceDataMd = {
"2019-01-01": {
dateUpdated: "Tue Jan 01 2019 00:00:00 GMT+0000",
dateUpdated: "Thu Jan 03 2019 00:00:00 GMT-0800",
title: "Diary Entry 1",
text: "This text is **bold** and _italic_.",
},
"2019-01-02": {
dateUpdated: "Tue Jan 01 2019 00:00:00 GMT+0000",
dateUpdated: "Thu Jan 03 2019 00:00:00 GMT-0800",
title: "Diary Entry 2",
text:
"Here's a bulleted list:\n\n- One\n- Two\n- Three\n\nAnd here's a numbered list:\n\n1. One\n2. Two\n3. Three",
Expand All @@ -20,12 +20,12 @@ export const referenceDataMd = {
*/
export const referenceDataTxt = {
"2019-01-01": {
dateUpdated: "Tue Jan 01 2019 00:00:00 GMT+0000",
dateUpdated: "Thu Jan 03 2019 00:00:00 GMT-0800",
title: "Diary Entry 1",
text: "This text is bold and italic.",
},
"2019-01-02": {
dateUpdated: "Tue Jan 01 2019 00:00:00 GMT+0000",
dateUpdated: "Thu Jan 03 2019 00:00:00 GMT-0800",
title: "Diary Entry 2",
text:
"Here's a bulleted list:\n\n- One\n- Two\n- Three\n\nAnd here's a numbered list:\n\n1. One\n2. Two\n3. Three",
Expand Down
4 changes: 3 additions & 1 deletion test/setup/setup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import MockDate from "mockdate";
import moment from "moment-timezone";

// Set date for tests to make `moment()` return the same date as the one used in the sample import/
// export files
MockDate.set("Tue Jan 01 2019 00:00:00 GMT+0000");
MockDate.set("Thu Jan 03 2019 00:00:00 GMT-0800");
moment.tz.setDefault("America/Los_Angeles");
16 changes: 15 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,13 @@
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==

"@types/moment-timezone@^0.5.13":
version "0.5.13"
resolved "https://registry.yarnpkg.com/@types/moment-timezone/-/moment-timezone-0.5.13.tgz#0317ccc91eb4c7f4901704166166395c39276528"
integrity sha512-SWk1qM8DRssS5YR9L4eEX7WUhK/wc96aIr4nMa6p0kTk9YhGGOJjECVhIdPEj13fvJw72Xun69gScXSZ/UmcPg==
dependencies:
moment ">=2.14.0"

"@types/node@*":
version "13.1.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.1.8.tgz#1d590429fe8187a02707720ecf38a6fe46ce294b"
Expand Down Expand Up @@ -7350,7 +7357,14 @@ modify-filename@^1.1.0:
resolved "https://registry.yarnpkg.com/modify-filename/-/modify-filename-1.1.0.tgz#9a2dec83806fbb2d975f22beec859ca26b393aa1"
integrity sha1-mi3sg4Bvuy2XXyK+7IWcoms5OqE=

moment@^2.22.2:
moment-timezone@^0.5.28:
version "0.5.28"
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.28.tgz#f093d789d091ed7b055d82aa81a82467f72e4338"
integrity sha512-TDJkZvAyKIVWg5EtVqRzU97w0Rb0YVbfpqyjgu6GwXCAohVRqwZjf4fOzDE6p1Ch98Sro/8hQQi65WDXW5STPw==
dependencies:
moment ">= 2.9.0"

"moment@>= 2.9.0", moment@>=2.14.0, moment@^2.22.2:
version "2.24.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==
Expand Down

0 comments on commit b55b8dd

Please sign in to comment.