Skip to content

Commit

Permalink
Update date format to remove yesterday (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
henningmu authored Jan 23, 2020
1 parent 62e4512 commit 74208c2
Show file tree
Hide file tree
Showing 19 changed files with 62 additions and 32 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Reactist follows [semantic versioning](https://semver.org/) and doesn't introduce breaking changes (API-wise) in minor or patch releases. However, the appearance of a component might change in a minor or patch release so keep an eye on redesigns and make sure your app still looks and feels like you expect it.

## 2.0.2

- [Tweak] Changed time formatting from `yesterday` to `1d`

## 2.0.1

- _Empty release_
Expand Down
2 changes: 1 addition & 1 deletion dist/reactist.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reactist.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/iframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@
}</script><style>#root[hidden],
#docs-root[hidden] {
display: none !important;
}</style></head><body><div class="sb-nopreview sb-wrapper"><div class="sb-nopreview_main"><h1 class="sb-nopreview_heading sb-heading">No Preview</h1><p>Sorry, but you either have no stories or none are selected somehow.</p><ul><li>Please check the Storybook config.</li><li>Try reloading the page.</li></ul><p>If the problem persists, check the browser console, or the terminal you've run Storybook from.</p></div></div><div class="sb-errordisplay sb-wrapper"><pre id="error-message" class="sb-heading"></pre><pre class="sb-errordisplay_code"><code id="error-stack"></code></pre></div><div id="root"></div><div id="docs-root"></div><script src="runtime~main.4d5e9381e44475509d3f.bundle.js"></script><script src="vendors~main.4d5e9381e44475509d3f.bundle.js"></script><script src="main.4d5e9381e44475509d3f.bundle.js"></script></body></html>
}</style></head><body><div class="sb-nopreview sb-wrapper"><div class="sb-nopreview_main"><h1 class="sb-nopreview_heading sb-heading">No Preview</h1><p>Sorry, but you either have no stories or none are selected somehow.</p><ul><li>Please check the Storybook config.</li><li>Try reloading the page.</li></ul><p>If the problem persists, check the browser console, or the terminal you've run Storybook from.</p></div></div><div class="sb-errordisplay sb-wrapper"><pre id="error-message" class="sb-heading"></pre><pre class="sb-errordisplay_code"><code id="error-stack"></code></pre></div><div id="root"></div><div id="docs-root"></div><script src="runtime~main.daebffa236aa977811c0.bundle.js"></script><script src="vendors~main.daebffa236aa977811c0.bundle.js"></script><script src="main.daebffa236aa977811c0.bundle.js"></script></body></html>
2 changes: 0 additions & 2 deletions docs/main.4d5e9381e44475509d3f.bundle.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/main.4d5e9381e44475509d3f.bundle.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions docs/main.daebffa236aa977811c0.bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/main.daebffa236aa977811c0.bundle.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion docs/runtime~main.4d5e9381e44475509d3f.bundle.js.map

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/runtime~main.daebffa236aa977811c0.bundle.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions lib/Time.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,8 @@ var TimeUtils = {
shortFormatCurrentYear = _config$shortFormatCu === void 0 ? this.SHORT_FORMAT_CURRENT_YEAR : _config$shortFormatCu,
_config$shortFormatPa = config.shortFormatPastYear,
shortFormatPastYear = _config$shortFormatPa === void 0 ? this.SHORT_FORMAT_PAST_YEAR : _config$shortFormatPa,
_config$yesterday = config.yesterday,
yesterday = _config$yesterday === void 0 ? 'yesterday' : _config$yesterday,
_config$daysSuffix = config.daysSuffix,
daysSuffix = _config$daysSuffix === void 0 ? 'd' : _config$daysSuffix,
_config$hoursSuffix = config.hoursSuffix,
hoursSuffix = _config$hoursSuffix === void 0 ? 'h' : _config$hoursSuffix,
_config$minutesSuffix = config.minutesSuffix,
Expand All @@ -624,7 +624,7 @@ var TimeUtils = {
return date.format(shortFormatPastYear);
}
} else if (diffDays === 1) {
return yesterday;
return "".concat(diffDays).concat(daysSuffix);
} else if (diffHours > 0 && diffHours <= 23) {
return "".concat(diffHours).concat(hoursSuffix);
} else if (diffMinutes > 0 && diffMinutes <= 59) {
Expand Down Expand Up @@ -835,7 +835,7 @@ Time_Time.propTypes = {
shortFormatCurrentYear: external_prop_types_default.a.string,
shortFormatPastYear: external_prop_types_default.a.string,
fullFormat: external_prop_types_default.a.string,
yesterday: external_prop_types_default.a.string,
daysSuffix: external_prop_types_default.a.string,
hoursSuffix: external_prop_types_default.a.string,
minutesSuffix: external_prop_types_default.a.string,
momentsAgo: external_prop_types_default.a.string
Expand All @@ -848,7 +848,7 @@ Time_Time.defaultProps = {
refresh: true,
config: {
locale: 'en',
yesterday: 'yesterday',
daysSuffix: 'd',
hoursSuffix: 'h',
minutesSuffix: 'm',
momentsAgo: 'moments ago'
Expand Down
43 changes: 31 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@doist/reactist",
"version": "2.0.1",
"version": "2.0.2",
"description": "Open source React components by Doist",
"main": "./dist/reactist.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Time.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Time.propTypes = {
shortFormatCurrentYear: PropTypes.string,
shortFormatPastYear: PropTypes.string,
fullFormat: PropTypes.string,
yesterday: PropTypes.string,
daysSuffix: PropTypes.string,
hoursSuffix: PropTypes.string,
minutesSuffix: PropTypes.string,
momentsAgo: PropTypes.string
Expand All @@ -142,7 +142,7 @@ Time.defaultProps = {
refresh: true,
config: {
locale: 'en',
yesterday: 'yesterday',
daysSuffix: 'd',
hoursSuffix: 'h',
minutesSuffix: 'm',
momentsAgo: 'moments ago'
Expand Down
4 changes: 2 additions & 2 deletions src/components/utils/TimeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const TimeUtils = {
locale = 'en',
shortFormatCurrentYear = this.SHORT_FORMAT_CURRENT_YEAR,
shortFormatPastYear = this.SHORT_FORMAT_PAST_YEAR,
yesterday = 'yesterday',
daysSuffix = 'd',
hoursSuffix = 'h',
minutesSuffix = 'm',
momentsAgo = 'moments ago'
Expand All @@ -32,7 +32,7 @@ const TimeUtils = {
return date.format(shortFormatPastYear)
}
} else if (diffDays === 1) {
return yesterday
return `${diffDays}${daysSuffix}`
} else if (diffHours > 0 && diffHours <= 23) {
return `${diffHours}${hoursSuffix}`
} else if (diffMinutes > 0 && diffMinutes <= 59) {
Expand Down
7 changes: 7 additions & 0 deletions src/components/utils/__tests__/TimeUtils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ describe('Time Utils', () => {
expect(TimeUtils.timeAgo(testDate)).toBe('10h')
})

it('timeAgo == 1d returns `1d`', () => {
const testDate = dayjs()
.subtract(1, 'days')
.unix()
expect(TimeUtils.timeAgo(testDate)).toBe('1d')
})

it('timeAgo < 7d returns MM/DD/YYYY', () => {
const testDate = dayjs()
.subtract(2, 'days')
Expand Down

0 comments on commit 74208c2

Please sign in to comment.