Merge branch 'dev' into 5919-locker
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-05-13 12:02:17 +00:00
commit b902a1a7f7
3 changed files with 12 additions and 12 deletions

View File

@ -1,3 +1,5 @@
const moment = require('moment');
module.exports = Self => {
Self.remoteMethodCtx('resendWeeklyHourEmail', {
description: 'Send the records for the week of the date provided',
@ -31,7 +33,8 @@ module.exports = Self => {
Object.assign(myOptions, options);
const yearNumber = dated.getFullYear();
const weekNumber = getWeekNumber(dated);
const weekNumber = moment(dated).isoWeek();
const workerTimeControlMail = await models.WorkerTimeControlMail.findOne({
where: {
workerFk: workerId,
@ -54,15 +57,4 @@ module.exports = Self => {
return false;
};
function getWeekNumber(date) {
const tempDate = new Date(date);
let dayOfWeek = tempDate.getDay();
dayOfWeek = (dayOfWeek === 0) ? 7 : dayOfWeek;
const firstDayOfWeek = new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate() - (dayOfWeek - 1));
const firstDayOfYear = new Date(tempDate.getFullYear(), 0, 1);
const differenceInMilliseconds = firstDayOfWeek.getTime() - firstDayOfYear.getTime();
const weekNumber = Math.floor(differenceInMilliseconds / (1000 * 60 * 60 * 24 * 7)) + 1;
return weekNumber;
}
};

View File

@ -39,6 +39,7 @@
"loopback-context": "^3.5.2",
"loopback-datasource-juggler": "3.36.1",
"md5": "^2.2.1",
"moment": "^2.30.1",
"mysql": "2.18.1",
"node-ssh": "^11.0.0",
"object.pick": "^1.3.0",

View File

@ -83,6 +83,9 @@ dependencies:
md5:
specifier: ^2.2.1
version: 2.3.0
moment:
specifier: ^2.30.1
version: 2.30.1
mysql:
specifier: 2.18.1
version: 2.18.1
@ -10202,6 +10205,10 @@ packages:
to-iso-string: 0.0.2
dev: false
/moment@2.30.1:
resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==}
dev: false
/ms@0.7.1:
resolution: {integrity: sha512-lRLiIR9fSNpnP6TC4v8+4OU7oStC01esuNowdQ34L+Gk8e5Puoc88IqJ+XAY/B3Mn2ZKis8l8HX90oU8ivzUHg==}
dev: false