Skip to content

Commit

Permalink
fix xsd:dateTime value generation for 0 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
s-tittel committed Jul 8, 2024
1 parent 356687c commit 89b8853
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>&lt;shacl-form&gt; demo</title>
<link rel="stylesheet" href="./style.css">
<!-- "@ulb-darmstadt/shacl-form": "https://cdn.jsdelivr.net/npm/@ulb-darmstadt/[email protected].4/dist/" -->
<!-- "@ulb-darmstadt/shacl-form": "https://cdn.jsdelivr.net/npm/@ulb-darmstadt/[email protected].6/dist/" -->
<!-- "@ulb-darmstadt/shacl-form": "./" -->
<script type="importmap">
{
"imports": {
"@ulb-darmstadt/shacl-form/": "https://cdn.jsdelivr.net/npm/@ulb-darmstadt/[email protected].5/dist/"
"@ulb-darmstadt/shacl-form/": "https://cdn.jsdelivr.net/npm/@ulb-darmstadt/[email protected].6/dist/"
}
}
</script>
Expand Down
4 changes: 4 additions & 0 deletions src/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export function toRDF(editor: Editor): Literal | NamedNode | undefined {
else if (editor['type'] === 'file' && editor['binaryData']) {
value = editor['binaryData']
}
else if (editor['type'] === 'datetime-local') {
// if seconds in value are 0, the input field omits them which is then not a valid xsd:dateTime
value = new Date(value).toISOString().slice(0, 19)
}
return DataFactory.literal(value, languageOrDatatype)
}
} else if (editor['type'] === 'checkbox' || editor.getAttribute('type') === 'checkbox') {
Expand Down

0 comments on commit 89b8853

Please sign in to comment.