Merge pull request #1741 from strongloop/fix/datestring-ctor-3x
Fix DateString ctor to accept DateString instances
This commit is contained in:
commit
548f3018a9
|
@ -53,6 +53,10 @@ function DateString(value) {
|
|||
return new DateString(value);
|
||||
}
|
||||
|
||||
if (value instanceof DateString) {
|
||||
value = value.when;
|
||||
}
|
||||
|
||||
if (typeof(value) !== 'string') {
|
||||
throw new Error('Input must be a string');
|
||||
}
|
||||
|
|
|
@ -44,6 +44,13 @@ describe('DateString', function() {
|
|||
// The internal date representation should also be updated!
|
||||
date._date.toString().should.eql(d.toString());
|
||||
});
|
||||
|
||||
it('should accept DateString instance', function() {
|
||||
const input = new DateString('2015-01-01');
|
||||
const inst = new DateString(input);
|
||||
inst.toString().should.equal('2015-01-01');
|
||||
});
|
||||
|
||||
it('should return custom inspect output', function() {
|
||||
const date = new DateString('2015-01-01');
|
||||
const result = inspect(date);
|
||||
|
|
Loading…
Reference in New Issue