Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
Verifique que la fecha ingresada en un formulario PDF sea el inicio de un período de pago

Trabajando en un formulario PDF en LiveCycle Designer, tengo un campo donde los empleados ingresarán la fecha efectiva propuesta para un cambio de horario. Estos solo pueden ser efectivos al comienzo de un período de pago, que es cada dos domingos. (Como referencia, el domingo 30 de enero de 2022 es el comienzo de un período de pago).

He probado muchas formas de usar declaraciones if y el método date.getDay(), pero encuentro que el método getDay a veces devuelve el número incorrecto (el empleado ingresa una fecha para un domingo, pero el código obtiene un valor de getDay de 1 en lugar de 0). Supongo que esto tiene algo que ver con la hora local, pero no estoy seguro.

Como referencia, aquí está el código que tengo actualmente en mi evento de cambio. No puedo decir con certeza que el resto funcione, ya que no puedo superar el problema de getDay. De todos modos, agradezco una solución a mi problema de getDay o una solución más elegante a todo este problema que lo evite.

 topmostSubform.Page1.Artifact[3].dateEffective::change - (JavaScript, client) // Check if entered date is a Sunday at the start of a pay period. // For reference, Sunday 1/30/2022 is the start of a pay period. // perform this check only if something is entered in this field xfa.host.messageBox('Value: ' + xfa.event.newText); xfa.host.messageBox('Is an entry?: ' + !(!xfa.event.newText)); if (!(!xfa.event.newText)) { const myRefDate = new Date(2022, 1, 30); const myDate = new Date(xfa.event.newText); xfa.host.messageBox('Day: ' + myDate.getDay()); // first check if entered date is a Sunday. If so, then execute the other code. if (myDate.getDay() == 0) { const diffTime = Math.abs(myRefDate - myDate); xfa.host.messageBox('diffTime: ' + diffTime); const diffDays = diffTime / (1000 * 60 * 60 * 24); // includes fractional days xfa.host.messageBox('diffDays: ' + diffDays); const diffPP = diffDays / 14; // includes fractional parts of a 14-day pay period xfa.host.messageBox('diffPP: ' + diffPP); const remainderPP = diffPP % 1; // calculate remainder of diffPP xfa.host.messageBox('remainderPP: ' + remainderPP); // if the remainderPP value indicates that myDate is more than 1 day from a Sunday, then fail if (remainderPP * 14 > 1) { // messagebox with error xfa.host.messageBox('Error1: You must enter the date for a Sunday that is the start of a pay period. Check your Pay/Holiday Schedule.'); xfa.host.setFocus(this.name); } }else{ xfa.host.messageBox('Error2: You must enter the date for a Sunday that is the start of a pay period. Check your Pay/Holiday Schedule.'); xfa.host.setFocus(this.name); } };
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!