fix: Set TZ to UTC

This commit is contained in:
Josepablo C
2025-07-29 22:08:41 -06:00
parent 0f8a17b630
commit cdc7e69598
5 changed files with 15 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
"use strict";
const apiConfig = require( '../config/apiConfig.json' );
const crypto = require('crypto');
const moment = require('moment');
const { S3Client, GetObjectCommand } = require('@aws-sdk/client-s3');
const s3Client = new S3Client({
@@ -44,13 +45,15 @@ function genKey( len = 6, key="" ){
* @param {*} date
*/
function normalizeDate( date ){
let in_date = new Date( date );
let year = in_date.getFullYear();
let monthIndex = in_date.getMonth();
let day = in_date.getDate();
// new Date(year, monthIndex, day, hours, minutes, seconds, milliseconds);
// return new Date( year, monthIndex, day, 0, 0, 0, 0 );
return new Date( Date.UTC( year, monthIndex, day, 0, 0, 0, 0 ) );
process.env.TZ='utc';
let in_date = moment( date, 'YYYY/MM/DD' );
let year = in_date.get('year');
let monthIndex = in_date.get('month');
let day = in_date.get('date');
let normalized_date = new Date( year, monthIndex, day, 0, 0, 0, 0 ).toISOString();
// let normalized_date = moment( in_date, 'YYYY/MM/DD' ).toISOString();
console.log( `${date} -> ${normalized_date}` );
return normalized_date;
}
function getPagination( query ){