Repository: toml-rs/toml (language: rust)

Issue:
Users can't determine what kind of DateTime is included
For me, this is for building on top of #111 to properly encode the data for validation, but I imagine this would be generally useful.  `toml_edit::DateTime` is `pub` but not exposed in a `pub` mod.

Should we have `toml_edit::DateTime` or split out the cases directly in `toml_edit::Value`?  I lean towards the latter as I'm unsure the value for having an extra layer but that extra layer requires a lot of verbosity to access.


Discussion / hints:
For now, in my branch, I will make it `pub` as-is since that is the least disruptive (no breaking change).  We can always change it later.

Fix patch:
diff --git a/src/lib.rs b/src/lib.rs
index 31d64718..8f12f301 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -84,5 +84,5 @@ pub use crate::document::Document;
 pub use crate::key::Key;
 pub use crate::parser::TomlError;
 pub use crate::table::{array, table, value, Item, Iter, IterMut, Table, TableLike};
-pub use crate::value::{Array, ArrayIter, InlineTable, Value};
+pub use crate::value::{Array, ArrayIter, DateTime, InlineTable, Value};
 pub use formatted::decorated;


Test patch:
diff --git a/tests/decoder_compliance.rs b/tests/decoder_compliance.rs
index 17d41a0f..616501e3 100644
--- a/tests/decoder_compliance.rs
+++ b/tests/decoder_compliance.rs
@@ -6,8 +6,6 @@ fn main() {
             "valid/array/array.toml",
             "valid/comment/everywhere.toml",
             "valid/datetime/datetime.toml",
-            "valid/datetime/local-date.toml",
-            "valid/datetime/local-time.toml",
             "valid/datetime/local.toml",
             "valid/datetime/milliseconds.toml",
             "valid/datetime/timezone.toml",
@@ -72,9 +70,20 @@ fn value_to_encoded(
         toml_edit::Value::Float(v) => Ok(toml_test_harness::Encoded::Value(
             toml_test_harness::EncodedValue::from(*v.value()),
         )),
-        toml_edit::Value::DateTime(v) => Ok(toml_test_harness::Encoded::Value(
-            toml_test_harness::EncodedValue::from(v.value().to_string()),
-        )),
+        toml_edit::Value::DateTime(v) => match *v.value() {
+            toml_edit::DateTime::OffsetDateTime(v) => Ok(toml_test_harness::Encoded::Value(
+                toml_test_harness::EncodedValue::from(v.to_string()),
+            )),
+            toml_edit::DateTime::LocalDateTime(v) => Ok(toml_test_harness::Encoded::Value(
+                toml_test_harness::EncodedValue::DatetimeLocal(v.to_string()),
+            )),
+            toml_edit::DateTime::LocalDate(v) => Ok(toml_test_harness::Encoded::Value(
+                toml_test_harness::EncodedValue::DateLocal(v.to_string()),
+            )),
+            toml_edit::DateTime::LocalTime(v) => Ok(toml_test_harness::Encoded::Value(
+                toml_test_harness::EncodedValue::TimeLocal(v.to_string()),
+            )),
+        },
         toml_edit::Value::Boolean(v) => Ok(toml_test_harness::Encoded::Value(
             toml_test_harness::EncodedValue::from(*v.value()),
         )),