Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New date helper using momentjs 'fromNow' method #1350

Merged
merged 6 commits into from
Nov 7, 2015
Merged

New date helper using momentjs 'fromNow' method #1350

merged 6 commits into from
Nov 7, 2015

Conversation

borisschapira
Copy link
Contributor

Moment.js provides a quite useful function for relative time, it would be a shame not to use it ;)

Boris Schapira added 3 commits June 23, 2015 22:41
Moment.js provides a quite useful function for relative time, it would be a shame not to use it ;)
@Xuanwo
Copy link
Contributor

Xuanwo commented Jun 24, 2015

Looks wonderful~
Make it a question for @tommy351

@@ -5,17 +5,21 @@ var isMoment = moment.isMoment;
var isDate = require('util').isDate;

function output(date, format, lang, timezone){
if (date == null) date = moment();
if (typeof myVar === 'undefined' || date === null) date = moment();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

== null can detect both undefined and null.

@tommy351
Copy link
Member

It's not a good idea to write fromNow logic in the output function. You should separate it.

@borisschapira
Copy link
Contributor Author

@tommy351 Is it better like this, only checking for format nullity in output (I dunno how to do it without changing something to output) ?

@tommy351
Copy link
Member

I think you can rename the output function to getDate or transformDate and only let this function check types and apply locale and timezone and format the date in each helpers.

@borisschapira
Copy link
Contributor Author

Better ?

@Xuanwo
Copy link
Contributor

Xuanwo commented Jul 15, 2015

@tommy351

@tommy351 tommy351 merged commit 7278da6 into hexojs:master Nov 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants