Skip to content

Conversation

@nnsathish
Copy link

Currently, it defaults to Time.now.utc which is not reasonably fair.
Also git commands like git log/show defaults to epoch time.

Currently, it defaults to Time.now.utc which is not reasonably fair.
Also git commands like git log/show defaults to epoch time.

Choose a reason for hiding this comment

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

LGTM. BTW, can we refactor this ? the whole scheme of nested conditional looks ugly to me ... possibly we could use a combination of guard clause and switch/case.

Copy link
Author

Choose a reason for hiding this comment

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

What would be the gain, if we do rewrite this code using case..when ? I don't think we can do it in a fewer lines of code, than the nested if.

Choose a reason for hiding this comment

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

I think we can write it same number of lines with better readability.
I think i will refactor this code and send you a pull eventually i have a feeling this could be really improved.

Choose a reason for hiding this comment

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

How about trying Time.rfc2822(date). It throws ArgumentError when date is not formatted per RFC2822; we'd catch this exception and return Time.at(0).utc in such cases.

@metacritical
Copy link

Besides the above comments overall it looks good to me.

@nnsathish
Copy link
Author

I've updated the code to address the PR comments. Thanks @amujumdar and @pankajdoharey

Choose a reason for hiding this comment

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

Let's just call it parse_date. It can be used to parse author or committer date.

Copy link
Author

Choose a reason for hiding this comment

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

Sure Abhay. Updated it.

amujumdar added a commit that referenced this pull request Jan 28, 2014
OTWO-2996 Default to EPOCH time when the git parser don't find a date
@amujumdar amujumdar merged commit 5f5ef92 into blackducksoftware:master Jan 28, 2014
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