fix(loads): Normalize dates on post and patch (remove time from dates)
This commit is contained in:
@@ -12,11 +12,18 @@ const proposalsModel = getModel('proposals');
|
||||
*/
|
||||
async function onDelivered( userId, elementId ){
|
||||
const load = await loadsModel.findById( elementId );
|
||||
|
||||
if( !load ){
|
||||
/// Nothing to do, invalid load
|
||||
return;
|
||||
}
|
||||
|
||||
const proposal_list = await proposalsModel.find({
|
||||
load: elementId,
|
||||
is_accepted: true,
|
||||
is_completed: false
|
||||
});
|
||||
|
||||
const vehicle_list = await vehiclesModel.find({
|
||||
active_load: elementId
|
||||
});
|
||||
|
||||
@@ -39,6 +39,19 @@ function genKey( len = 6, key="" ){
|
||||
return otp_str.slice(0,len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a datetime input and produces a date only output.
|
||||
* @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 );
|
||||
}
|
||||
|
||||
function getPagination( query ){
|
||||
let limit = {
|
||||
page : 0,
|
||||
@@ -101,4 +114,4 @@ async function downloadFile( bucket, key, obj_id ){
|
||||
return s3resp;
|
||||
}
|
||||
|
||||
module.exports = { genKey , toSha256, getPagination, getPage, queryPage, downloadFile};
|
||||
module.exports = { genKey , toSha256, normalizeDate, getPagination, getPage, queryPage, downloadFile};
|
||||
Reference in New Issue
Block a user