diff --git a/docs/src/values.html b/docs/src/values.html index eab1931..933438e 100644 --- a/docs/src/values.html +++ b/docs/src/values.html @@ -202,7 +202,7 @@

Formatting

  • %%: A literal percent character.
  • - If no specification is given, Date values default to %Y-%m-%d %H:%M:%S. + If no specification is given, Date values default to the original input text or %Y-%m-%d %H:%M:%S if none exists.

    @@ -291,7 +291,7 @@

    Examples

    Formatting

    DateDelta does not provide formatting options at the moment. - By default values are formatted as +Dd HH:MM:SS. + By default values are returned as they were input or are formatted as +Dd HH:MM:SS if no original input exists. Use attributes to assemble a custom format.

    diff --git a/test/test_values.js b/test/test_values.js index 6ee0a87..ce64853 100644 --- a/test/test_values.js +++ b/test/test_values.js @@ -120,11 +120,17 @@ describe("Value formatting", function () { }); it("DateDeltaValue default format", function() { - let pos = new DateDeltaValue("+5m"); + const pos = new DateDeltaValue("+5m"); + assert.strictEqual(pos.toString(), "+5m"); + pos._TEXT = null; // TODO create a proper mechanism to obtain default formatting assert.strictEqual(pos.toString(), "+0d 00:05:00"); - let neg = new DateDeltaValue("-251h"); + const neg = new DateDeltaValue("-251h"); + assert.strictEqual(neg.toString(), "-251h"); + neg._TEXT = null; // TODO create a proper mechanism to obtain default formatting assert.strictEqual(neg.toString(), "-10d 11:00:00"); - let zero = new DateDeltaValue("0d"); + const zero = new DateDeltaValue("0d"); + assert.strictEqual(zero.toString(), "0d"); + zero._TEXT = null; // TODO create a proper mechanism to obtain default formatting assert.strictEqual(zero.toString(), "+0d 00:00:00"); });