Skip to content

Commit

Permalink
git dates: support some natural language formats
Browse files Browse the repository at this point in the history
  • Loading branch information
dimofte committed Mar 12, 2020
1 parent e588797 commit a6d6044
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ const welcome = () => {
\\/_____________/\\/_/ \\_\\/
If you don't see formatted output, try to increase width of the terminal to have more space.
Some degree of natural language is supported in date formatting, e.g.
- "This Friday at 13:15"
- "5 days ago"
- "2 weeks from now"
`);
};

Expand Down
3 changes: 2 additions & 1 deletion src/git.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import moment from 'moment';
import chrono from 'chrono-node';
import throwError from './errors/throwError';
import gitLogConverter from './gitLogConverter';
import execute from './execute';
Expand All @@ -17,7 +18,7 @@ export const getCommits = async (path, { count, hash }) => {
};

export const formatGitDate = (date) => {
const momentDate = moment(date);
const momentDate = moment(chrono.parseDate(date));
if (!momentDate.isValid()) {
throwError(new Error("DATE_INVALID"));
}
Expand Down

0 comments on commit a6d6044

Please sign in to comment.