@shisyamo4131/air-guard-v2-schemas 2.3.7-dev.21 → 2.3.7-dev.22
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 +1 -1
- package/src/Employee.js +31 -11
package/package.json
CHANGED
package/src/Employee.js
CHANGED
|
@@ -154,30 +154,50 @@ export default class Employee extends FireModel {
|
|
|
154
154
|
|
|
155
155
|
/**
|
|
156
156
|
* 生年月日から年齢を計算します。
|
|
157
|
-
* @returns {number|null}
|
|
157
|
+
* @returns {{years: number, months: number}|null} 年齢(年数と月数)。dateOfBirthが設定されていない場合はnull。
|
|
158
158
|
*/
|
|
159
159
|
get age() {
|
|
160
160
|
if (!this.dateOfBirth) return null;
|
|
161
161
|
const today = new Date();
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
|
|
163
|
+
let years = today.getUTCFullYear() - this.dateOfBirth.getUTCFullYear();
|
|
164
|
+
let months = today.getUTCMonth() - this.dateOfBirth.getUTCMonth();
|
|
165
|
+
const days = today.getUTCDate() - this.dateOfBirth.getUTCDate();
|
|
166
|
+
|
|
167
|
+
if (days < 0) {
|
|
168
|
+
months--;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (months < 0) {
|
|
172
|
+
years--;
|
|
173
|
+
months += 12;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return { years, months };
|
|
167
177
|
}
|
|
168
178
|
|
|
169
179
|
/**
|
|
170
180
|
* 入社日からの勤続年数を計算します。
|
|
171
|
-
* @returns {number|null}
|
|
181
|
+
* @returns {{years: number, months: number}|null} 勤続年数(年数と月数)。dateOfHireが設定されていない場合はnull。
|
|
172
182
|
*/
|
|
173
183
|
get yearsOfService() {
|
|
174
184
|
if (!this.dateOfHire) return null;
|
|
175
185
|
const today = new Date();
|
|
186
|
+
|
|
176
187
|
let years = today.getUTCFullYear() - this.dateOfHire.getUTCFullYear();
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
188
|
+
let months = today.getUTCMonth() - this.dateOfHire.getUTCMonth();
|
|
189
|
+
const days = today.getUTCDate() - this.dateOfHire.getUTCDate();
|
|
190
|
+
|
|
191
|
+
if (days < 0) {
|
|
192
|
+
months--;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (months < 0) {
|
|
196
|
+
years--;
|
|
197
|
+
months += 12;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return { years, months };
|
|
181
201
|
}
|
|
182
202
|
|
|
183
203
|
/**
|