fable 3.0.146 → 3.0.147

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fable",
3
- "version": "3.0.146",
3
+ "version": "3.0.147",
4
4
  "description": "A service dependency injection, configuration and logging library.",
5
5
  "main": "source/Fable.js",
6
6
  "scripts": {
package/source/Fable.js CHANGED
@@ -310,7 +310,27 @@ class Fable extends libFableServiceBase.CoreServiceProviderBase
310
310
  }
311
311
 
312
312
  return false;
313
- }
313
+ }
314
+
315
+
316
+ /**
317
+ * Generate a safe string to use in filenames for a date. Useful for log file uniqueness and temporary outputs.
318
+ *
319
+ * @static
320
+ * @param {Date} pDate - An optional javascript Date object to generate a datestamp for.
321
+ * @returns {string} - A string formatted as YYYY-MM-DD-HH-MM-SS
322
+ */
323
+ static generateFileNameDateStamp(pDate)
324
+ {
325
+ const tmpDate = pDate || new Date();
326
+ const tmpYear = tmpDate.getFullYear();
327
+ const tmpMonth = String(tmpDate.getMonth() + 1).padStart(2, '0');
328
+ const tmpDay = String(tmpDate.getDate()).padStart(2, '0');
329
+ const tmpHour = String(tmpDate.getHours()).padStart(2, '0');
330
+ const tmpMinute = String(tmpDate.getMinutes()).padStart(2, '0');
331
+ const tmpSecond = String(tmpDate.getSeconds()).padStart(2, '0');
332
+ return `${tmpYear}-${tmpMonth}-${tmpDay}-${tmpHour}-${tmpMinute}-${tmpSecond}`;
333
+ }
314
334
  }
315
335
 
316
336
  // This is for backwards compatibility
@@ -67,6 +67,17 @@ suite
67
67
  }
68
68
  );
69
69
  test
70
+ (
71
+ 'The static date stamp should work.',
72
+ function()
73
+ {
74
+ let tmpDateStamp = libFable.generateFileNameDateStamp();
75
+ Expect(tmpDateStamp).to.be.a('string');
76
+ Expect(tmpDateStamp.length).to.equal(19);
77
+ Expect(tmpDateStamp).to.match(/^\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2}$/);
78
+ }
79
+ );
80
+ test
70
81
  (
71
82
  'Logging should happen...',
72
83
  function(fDone)