Skip to content

Commit

Permalink
Convert common time helpers to Typescript (#2391)
Browse files Browse the repository at this point in the history
  • Loading branch information
lhsazevedo authored Oct 31, 2020
1 parent 21c2a4b commit 52e45aa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import dayjs from 'dayjs';
import * as Mithril from 'mithril';

/**
* The `fullTime` helper displays a formatted time string wrapped in a <time>
* tag.
*
* @param {Date} time
* @return {Object}
*/
export default function fullTime(time) {
export default function fullTime(time: Date): Mithril.Vnode {
const d = dayjs(time);

const datetime = d.format();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import dayjs from 'dayjs';
import * as Mithril from 'mithril';
import humanTimeUtil from '../utils/humanTime';

/**
* The `humanTime` helper displays a time in a human-friendly time-ago format
* (e.g. '12 days ago'), wrapped in a <time> tag with other information about
* the time.
*
* @param {Date} time
* @return {Object}
*/
export default function humanTime(time) {
export default function humanTime(time: Date): Mithril.Vnode {
const d = dayjs(time);

const datetime = d.format();
Expand Down
3 changes: 3 additions & 0 deletions js/src/common/utils/humanTime.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import dayjs from 'dayjs';
import 'dayjs/plugin/relativeTime';

/**
* The `humanTime` utility converts a date to a localized, human-readable time-
* ago string.
Expand Down

0 comments on commit 52e45aa

Please sign in to comment.