@beauraines/node-helpers 5.1.0 → 5.2.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [5.2.0](https://github.com/beauraines/node-helpers/compare/v5.1.0...v5.2.0) (2024-10-19)
6
+
7
+
8
+ ### Features
9
+
10
+ * **helper:** convert unix timestamp to date ([d885b45](https://github.com/beauraines/node-helpers/commit/d885b45abf182ae9bb8e210f129735d672ee766a))
11
+
5
12
  ## [5.1.0](https://github.com/beauraines/node-helpers/compare/v5.0.0...v5.1.0) (2024-10-16)
6
13
 
7
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beauraines/node-helpers",
3
- "version": "5.1.0",
3
+ "version": "5.2.0",
4
4
  "description": "Collection of node helpers",
5
5
  "main": "index.js",
6
6
  "repository": {
package/src/helpers.js CHANGED
@@ -114,6 +114,16 @@ function getEpochMillis() {
114
114
  return Date.now()
115
115
  }
116
116
 
117
+ /**
118
+ * Coverts a unix timestamp to an ISO-8601 date string.
119
+ *
120
+ * @param {number} timestamp A unix timestamp
121
+ * @returns String ISO-8601 formatted date
122
+ */
123
+ function unixTimestampToDate(timestamp) {
124
+ return (new Date(timestamp * 1000)).toISOString()
125
+ }
126
+
117
127
 
118
128
 
119
129
  /**
@@ -223,5 +233,6 @@ module.exports = {
223
233
  toTitleCase,
224
234
  toUpperSnakeCase,
225
235
  unixTimestamp,
236
+ unixTimestampToDate,
226
237
  writeFile
227
238
  }
@@ -38,5 +38,12 @@ describe('helpers',()=> {
38
38
  })
39
39
  })
40
40
 
41
+ it('should return the correct date-time for a timestamp',() =>{
42
+ const timestamp = 1729396788;
43
+ const expectedOutput = '2024-10-20T03:59:48.000Z';
44
+ const convertedDate = helper.unixTimestampToDate(timestamp);
45
+ expect(convertedDate).toBe(expectedOutput);
46
+ })
47
+
41
48
  })
42
49