Marwan
05/23/2022, 9:54 AMfunction formatDate(date) {
var formatedDate = format.format({
value: new Date(date),
type: format.Type.DATE,
});
return formatedDate.toString();
}
function formatDate2(date) {
var formatedDate = format.format({
value: new Date(date),
type: format.Type.DATETIME,
});
return formatedDate.toString().split(" ")[0];
}
function execute() {
try {
log.audit("formatDate", formatDate("2022-05-18T04:57:06.798Z"));
log.audit("formatDate2", formatDate2("2022-05-18T04:57:06.798Z"));
} catch (err) {
log.audit("Error", err);
}
}
This script prints
formatDate 17/5/2022
formatDate2 18/5/2022
Any idea why?
Why format.Type.DATE
gives a different result than format.Type.DATETIME
?CD
05/23/2022, 12:04 PMMarwan
05/23/2022, 12:10 PMbattk
05/23/2022, 1:17 PM"2022-05-18T06:59:59.999Z"
to "2022-05-18T07:00:00.000Z"
Marwan
05/23/2022, 1:26 PM"2022-05-18T06:59:59.999Z"
but not this "2022-05-18T07:00:00.000Z"
So why is that? I don't understandbattk
05/23/2022, 1:27 PMbattk
05/23/2022, 1:27 PMMarwan
05/23/2022, 1:27 PMbattk
05/23/2022, 1:28 PMMarwan
05/23/2022, 1:29 PMbattk
05/23/2022, 1:30 PMbattk
05/23/2022, 1:30 PMMarwan
05/23/2022, 1:31 PM18
in this case... right?battk
05/23/2022, 1:34 PM"2022-05-18T04:57:06.798Z"
is equivalent to
"2022-05-17T21:57:06.798-7:00"
Marwan
05/23/2022, 1:35 PMDATETIME
respects the timezone parameter, but DATE
doesn't... right?battk
05/23/2022, 1:38 PMMarwan
05/23/2022, 1:40 PMbattk
05/23/2022, 1:44 PMfunction doFormat(options, type) {
var value,
timezone = null,
undef = undefined;
if (type !== undef) {
value = options;
} else if (options !== undef && options !== null) {
value = options.value;
type = options.type;
timezone = options.timezone || null;
}
utilityFunctions.checkArgs([value, type], ["value", "type"], "format");
switch (type) {
case fieldTypeConstants.Type.DATE:
case fieldTypeConstants.Type.TIME:
case fieldTypeConstants.Type.TIMETRACK:
case fieldTypeConstants.Type.TIMEOFDAY:
case fieldTypeConstants.Type.INTEGER:
case fieldTypeConstants.Type.POSINTEGER:
case fieldTypeConstants.Type.PERCENT:
case fieldTypeConstants.Type.FLOAT:
case fieldTypeConstants.Type.POSFLOAT:
case fieldTypeConstants.Type.NONNEGFLOAT:
case fieldTypeConstants.Type.POSCURRENCY:
case fieldTypeConstants.Type.NONNEGCURRENCY:
case fieldTypeConstants.Type.CURRENCY:
case fieldTypeConstants.Type.CURRENCY2:
case fieldTypeConstants.Type.CHECKBOX:
case fieldTypeConstants.Type.PHONE:
case fieldTypeConstants.Type.FULLPHONE:
case fieldTypeConstants.Type.MMYYDATE:
case fieldTypeConstants.Type.RATE:
case fieldTypeConstants.Type.RATEHIGHPRECISION:
return formatter.format(value, type);
case fieldTypeConstants.Type.DATETIME:
case fieldTypeConstants.Type.DATETIMETZ:
return dateTimeZone.format(value, timezone);
default:
return value;
}
}
battk
05/23/2022, 1:45 PMMarwan
05/23/2022, 1:58 PM