lausannel commented on code in PR #25:
URL: 
https://github.com/apache/iotdb-client-csharp/pull/25#discussion_r1946425243


##########
src/Apache.IoTDB/Utils.cs:
##########
@@ -93,5 +94,38 @@ public List<TEndPoint> ParseSeedNodeUrls(List<string> 
nodeUrls)
             }
             return nodeUrls.Select(ParseTEndPointIpv4AndIpv6Url).ToList();
         }
+
+        public static DateTime ParseIntToDate(int dateInt)
+        {
+            if (dateInt < 10000101 || dateInt > 99991231)
+            {
+                throw new ArgumentException("Date must be between 10000101 and 
99991231.");
+            }
+            return new DateTime(dateInt / 10000, dateInt / 100 % 100, dateInt 
% 100);
+        }
+
+        public static int ParseDateToInt(DateTime? dateTime)
+        {
+          if (dateTime == null)
+          {
+              throw new ArgumentException("Date expression is none or empty.");
+          }
+          if(dateTime.Value.Year<1000)
+          {
+              throw new ArgumentException("Year must be between 1000 and 
9999.");
+          }
+          return dateTime.Value.Year * 10000 + dateTime.Value.Month * 100 + 
dateTime.Value.Day;
+        }
+
+        public static string ByteArrayToHexString(byte[] bytes)

Review Comment:
   Could we use `BitConverter.ToString(bytes).Replace("-", 
"").ToLowerInvariant()` here instead of manually iterating over the array?



##########
src/Apache.IoTDB/Utils.cs:
##########
@@ -93,5 +94,38 @@ public List<TEndPoint> ParseSeedNodeUrls(List<string> 
nodeUrls)
             }
             return nodeUrls.Select(ParseTEndPointIpv4AndIpv6Url).ToList();
         }
+
+        public static DateTime ParseIntToDate(int dateInt)

Review Comment:
   Can we use `DateTime.TryParseExact` (or `DateOnly.TryParseExact`) to handle 
integer-to-date conversion?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to