@wictorwilen/cocogen 1.0.49 → 1.0.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.0.50] - 2026-03-26
11
+
12
+ ### Fixed
13
+ - Generated .NET date-only parsers now accept ISO date-time inputs and truncate them to the source calendar date instead of falling back to `Date.MinValue`.
14
+
10
15
  ## [1.0.49] - 2026-03-26
11
16
 
12
17
  ### Fixed
@@ -301,6 +306,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
301
306
  - Collection values no longer split on commas; use semicolons instead.
302
307
 
303
308
  [Unreleased]: https://github.com/wictorwilen/cocogen/compare/v1.0.16...HEAD
309
+ [1.0.50]: https://github.com/wictorwilen/cocogen/compare/main...v1.0.50
304
310
  [1.0.49]: https://github.com/wictorwilen/cocogen/compare/main...v1.0.49
305
311
  [1.0.48]: https://github.com/wictorwilen/cocogen/compare/main...v1.0.48
306
312
  [1.0.47]: https://github.com/wictorwilen/cocogen/compare/main...v1.0.47
@@ -336,11 +336,34 @@ public static class RowParser
336
336
  public static Date ParseDate(string? value)
337
337
  {
338
338
  var v = ParseString(value);
339
- return Date.TryParse(v, CultureInfo.InvariantCulture, DateTimeStyles.None, out var date)
339
+ return TryParseDateValue(v, out var date)
340
340
  ? date
341
341
  : default;
342
342
  }
343
343
 
344
+ private static bool TryParseDateValue(string value, out Date date)
345
+ {
346
+ if (Date.TryParse(value, CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, out date))
347
+ {
348
+ return true;
349
+ }
350
+
351
+ if (DateTimeOffset.TryParse(value, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out var offsetValue))
352
+ {
353
+ date = Date.FromDateTime(offsetValue.DateTime);
354
+ return true;
355
+ }
356
+
357
+ if (DateTime.TryParse(value, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out var dateTimeValue))
358
+ {
359
+ date = Date.FromDateTime(dateTimeValue);
360
+ return true;
361
+ }
362
+
363
+ date = default;
364
+ return false;
365
+ }
366
+
344
367
  /// <summary>
345
368
  /// Parse a string collection from a row using the provided headers.
346
369
  /// </summary>
@@ -550,24 +573,24 @@ public static class RowParser
550
573
  if (value is JsonArray array)
551
574
  {
552
575
  return array
553
- .Select((entry) => Date.TryParse(ParseString(entry), CultureInfo.InvariantCulture, DateTimeStyles.None, out var date) ? date : default)
576
+ .Select((entry) => TryParseDateValue(ParseString(entry), out var date) ? date : default)
554
577
  .ToList();
555
578
  }
556
579
  if (value is JsonElement element && element.ValueKind == JsonValueKind.Array)
557
580
  {
558
581
  return element
559
582
  .EnumerateArray()
560
- .Select((entry) => Date.TryParse(ParseString(entry), CultureInfo.InvariantCulture, DateTimeStyles.None, out var date) ? date : default)
583
+ .Select((entry) => TryParseDateValue(ParseString(entry), out var date) ? date : default)
561
584
  .ToList();
562
585
  }
563
586
  var v = ParseString(value);
564
587
  if (v.Length == 0) return new List<Date>();
565
588
  <% if (inputFormat === "csv") { -%>
566
589
  return v.Split(';', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
567
- .Select((x) => Date.TryParse(x, CultureInfo.InvariantCulture, DateTimeStyles.None, out var date) ? date : default)
590
+ .Select((x) => TryParseDateValue(x, out var date) ? date : default)
568
591
  .ToList();
569
592
  <% } else { -%>
570
- return Date.TryParse(v, CultureInfo.InvariantCulture, DateTimeStyles.None, out var date)
593
+ return TryParseDateValue(v, out var date)
571
594
  ? new List<Date> { date }
572
595
  : new List<Date>();
573
596
  <% } -%>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wictorwilen/cocogen",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
4
4
  "description": "TypeSpec-driven Microsoft Copilot connector generator",
5
5
  "license": "MIT",
6
6
  "author": "Wictor Wilén <wictor@wictorwilen.se>",