mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
@@ -222,7 +222,11 @@ export class PayloadService {
|
||||
['dateTime', 'date', 'timestamp'].includes(field.type)
|
||||
);
|
||||
|
||||
if (dateColumns.length === 0) return payloads;
|
||||
const timeColumns = fieldsInCollection.filter(([_name, field]) => {
|
||||
return field.type === 'time';
|
||||
});
|
||||
|
||||
if (dateColumns.length === 0 && timeColumns.length === 0) return payloads;
|
||||
|
||||
for (const [name, dateColumn] of dateColumns) {
|
||||
for (const payload of payloads) {
|
||||
@@ -270,6 +274,22 @@ export class PayloadService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Some DB drivers (MS SQL f.e.) return time values as Date objects. For consistencies sake,
|
||||
* we'll abstract those back to hh:mm:ss
|
||||
*/
|
||||
for (const [name] of timeColumns) {
|
||||
for (const payload of payloads) {
|
||||
const value = payload[name];
|
||||
|
||||
if (!value) continue;
|
||||
|
||||
if (action === 'read') {
|
||||
if (value instanceof Date) payload[name] = format(value, 'HH:mm:ss');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return payloads;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user