@star-insure/sdk 4.1.2 → 4.1.3

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/dist/sdk.esm.js CHANGED
@@ -1098,19 +1098,27 @@ function _getAddressData() {
1098
1098
 
1099
1099
  /**
1100
1100
  * Calculate someone's age from a date of birth.
1101
- * @param date YYYY-MM-DD
1102
1101
  */
1103
1102
  function calculateAge(date) {
1104
- var today = new Date();
1105
- var birthDate = new Date(date);
1106
- var age = today.getFullYear() - birthDate.getFullYear();
1107
- var m = today.getMonth() - birthDate.getMonth();
1108
-
1109
- if (m < 0 || m === 0 && today.getDate() < birthDate.getDate()) {
1110
- return age - 1;
1103
+ if (!date) {
1104
+ return 0;
1111
1105
  }
1112
1106
 
1113
- return age;
1107
+ try {
1108
+ var today = new Date();
1109
+ var birthDate = new Date(date);
1110
+ var age = today.getFullYear() - birthDate.getFullYear();
1111
+ var m = today.getMonth() - birthDate.getMonth();
1112
+
1113
+ if (m < 0 || m === 0 && today.getDate() < birthDate.getDate()) {
1114
+ return age - 1;
1115
+ }
1116
+
1117
+ return age;
1118
+ } catch (error) {
1119
+ console.error(error);
1120
+ return 0;
1121
+ }
1114
1122
  }
1115
1123
 
1116
1124
  function calculateMonthly(_ref) {