From 663d105d3a9bd0b3c8905c17d705f6ec622e6836 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com>
Date: Mon, 9 Oct 2023 21:09:39 +0200
Subject: [PATCH] DOC: add in code documentation

---
 src/core/js/caosdb.js    | 9 +++++----
 src/core/js/edit_mode.js | 2 ++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/core/js/caosdb.js b/src/core/js/caosdb.js
index 5eb53a46..e834c3f7 100644
--- a/src/core/js/caosdb.js
+++ b/src/core/js/caosdb.js
@@ -330,9 +330,11 @@ var getEntityIdVersion = function (entity) {
 }
 
 /**
- * Take a date and a time and format it into a CaosDB compatible representation.
+ * Take a date, a time and subseconds and format it into a CaosDB compatible representation.
  * @param date A date
  * @param time A time
+ * @param subsec fractions of a seconds part of the time stamp; Must be empty
+ *               string if not used
  * @return A CaosDB compatible representation.
  */
 function input2caosdbDate(date, time, subsec) {
@@ -370,13 +372,13 @@ var getAllEntityPermissions = function (entity) {
 }
 
 /**
- * Take a datetime from caosdb and return a date and a time
+ * Take a datetime from caosdb and return a date, a time and the subseconds
  * suitable for html inputs.
  *
  * If the text contains only a date it is returned.
  *
  * @param text The string from CaosDB.
- * @return A new string for the input element.
+ * @return A list of strings for the input elements.
  */
 function caosdb2InputDate(text) {
     if (text.includes("T")) {
@@ -385,7 +387,6 @@ function caosdb2InputDate(text) {
         if (spl[1].includes(".")) {
             subsec = spl[1].split('.')[1]
         }
-        //TODO subsecond resolution is IGNORED!!!
         return [spl[0], spl[1].substring(0, 8), subsec];
     }
     return [text];
diff --git a/src/core/js/edit_mode.js b/src/core/js/edit_mode.js
index beff84e1..1148f0cb 100644
--- a/src/core/js/edit_mode.js
+++ b/src/core/js/edit_mode.js
@@ -513,6 +513,7 @@ var edit_mode = new function () {
         var _parse_single_datetime = function (field) {
             let time = $(field).find(":input[type='time']").val()
             let date = $(field).find(":input[type='date']").val();
+            // subseconds are stored in the subsec attribue of the input element
             let subsec = $(field).find(":input[type='time']").attr('subsec');
             if (time) {
                 return input2caosdbDate(date, time, subsec);
@@ -978,6 +979,7 @@ var edit_mode = new function () {
             let date = dateandtime[0];
             if (dateandtime.length > 1) {
                 let time = dateandtime[1];
+                // subseconds are stored in the subsec attribue of the input element
                 result = "<span><input type='date' value='" + date + "'/>" +
                     "<input type='time' subsec='"+dateandtime[2]+"' value='" + time + "'/></span>";
             } else if (property.value && ((property.name || "").toLowerCase() == "year" || (date.match(/-/g) || []).length == 0)) {
-- 
GitLab