@react-pakistan/util-functions 1.9.13 → 1.10.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.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A util function to create date from provided string
|
|
3
|
+
* eg: Saturday, 11/01/2020
|
|
4
|
+
*
|
|
5
|
+
* @returns formatted date - Saturday, 11/01/2020
|
|
6
|
+
* @author Taimoor Khan
|
|
7
|
+
* @remarks
|
|
8
|
+
*/
|
|
9
|
+
/** End file docs */
|
|
10
|
+
export declare const createDate: (date?: string | Date | undefined, tz?: string | undefined) => Date;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* A util function to create date from provided string
|
|
4
|
+
* eg: Saturday, 11/01/2020
|
|
5
|
+
*
|
|
6
|
+
* @returns formatted date - Saturday, 11/01/2020
|
|
7
|
+
* @author Taimoor Khan
|
|
8
|
+
* @remarks
|
|
9
|
+
*/
|
|
10
|
+
/** End file docs */
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createDate = void 0;
|
|
13
|
+
const date_fns_tz_1 = require("date-fns-tz");
|
|
14
|
+
const set_timezone_1 = require("./set-timezone");
|
|
15
|
+
const defaultTimezone = 'Asia/Karachi';
|
|
16
|
+
const createDate = (date, tz) => {
|
|
17
|
+
if (tz || !date) {
|
|
18
|
+
return (0, set_timezone_1.setTimezone)(date ? (0, date_fns_tz_1.toDate)(date) : new Date(), tz || defaultTimezone);
|
|
19
|
+
}
|
|
20
|
+
return (0, date_fns_tz_1.toDate)(date);
|
|
21
|
+
};
|
|
22
|
+
exports.createDate = createDate;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.setTimezone = void 0;
|
|
7
|
+
const date_fns_tz_1 = require("date-fns-tz");
|
|
8
|
+
const lodash_curry_1 = __importDefault(require("lodash.curry"));
|
|
9
|
+
exports.setTimezone = (0, lodash_curry_1.default)((date, timezone = 'Asia/Karachi') => (0, date_fns_tz_1.utcToZonedTime)(date, timezone));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-pakistan/util-functions",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "A library of all util functions",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -37,7 +37,10 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/react-pakistan/util-functions#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@microsoft/tsdoc": "^0.13.2"
|
|
40
|
+
"@microsoft/tsdoc": "^0.13.2",
|
|
41
|
+
"date-fns": "^2.28.0",
|
|
42
|
+
"date-fns-tz": "^1.3.0",
|
|
43
|
+
"lodash.curry": "^4.1.1"
|
|
41
44
|
},
|
|
42
45
|
"devDependencies": {
|
|
43
46
|
"@babel/core": "^7.17.5",
|
|
@@ -45,6 +48,7 @@
|
|
|
45
48
|
"@babel/preset-typescript": "^7.16.7",
|
|
46
49
|
"@react-pakistan/eslint-config-shared": "^1.4.16",
|
|
47
50
|
"@types/jest": "^27.4.1",
|
|
51
|
+
"@types/lodash.curry": "^4.1.6",
|
|
48
52
|
"@types/node": "^17.0.21",
|
|
49
53
|
"@types/react-redux": "^7.1.23",
|
|
50
54
|
"@types/styled-components": "^5.1.24",
|