Skip to content

Commit

Permalink
fix: Edm.DateTimeOffset parsing with and without precision (#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
marianfoo authored Jul 24, 2024
1 parent 093f422 commit 6649d53
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/ui5-cc-spreadsheetimporter/src/controller/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ export default class Parser extends ManagedObject {
}
try {
this.checkDate(date, metadataColumn, util, messageHandler, index);
payload[columnKey] = date;
if(!metadataColumn.precision){
// If precision is not defined, remove milliseconds from date (from '2023-11-25T00:00:00Z' to '2023-11-25T00:00:00.000Z')
// see https://github.com/spreadsheetimporter/ui5-cc-spreadsheetimporter/issues/600
payload[columnKey] = date.toISOString().replace(/\.\d{3}/, '')
} else {
payload[columnKey] = date;
}
} catch (error) {
this.addMessageToMessages("spreadsheetimporter.errorWhileParsing", util, messageHandler, index, [metadataColumn.label], rawValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default class MetadataHandlerV4 extends MetadataHandler {
}
propertyObject.type = property.$Type;
propertyObject.maxLength = property.$MaxLength;
propertyObject.precision = property.$Precision;
listObject.set(propertyName, propertyObject);
} else {
Log.warning(`SpreadsheetUpload: Property ${propertyName} not found`, undefined, "SpreadsheetUpload: MetadataHandler");
Expand Down
3 changes: 2 additions & 1 deletion packages/ui5-cc-spreadsheetimporter/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ export interface Tags {
}

export interface Property {
maxLength: number;
maxLength?: number;
type: string;
label: string;
precision?: number;
}
export type ListObject = Map<string, Property>;
export type PropertyArray = { [key: string]: any }[];
Expand Down

0 comments on commit 6649d53

Please sign in to comment.