Skip to content

Commit dd5a5a1

Browse files
committed
Added date method to commit, resolves nodegit#62
1 parent 45c9d2c commit dd5a5a1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/commit.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,24 @@ Commit.prototype.time = function(callback) {
123123
});
124124
};
125125

126+
/**
127+
* Retrieve the commit time as a Date object.
128+
*
129+
* @param {Commit~dateCallback} callback
130+
*/
131+
Commit.prototype.date = function(callback) {
132+
/**
133+
* @callback Commit~dateCallback Callback executed on date retrieval.
134+
* @param {GitError|null} error An Error or null if successful.
135+
* @param {Date|null} time Retrieved time as a Date object.
136+
*/
137+
this.time(function(error, time) {
138+
if (success(error, callback)) {
139+
callback(null, new Date(time * 1000));
140+
}
141+
});
142+
};
143+
126144
/**
127145
* Retrieve the commit's positive or negative timezone offset, in minutes from UTC.
128146
*

0 commit comments

Comments
 (0)