diff --git a/gxml/GomProperty.vala b/gxml/GomProperty.vala index 34ec9a6642bcebf86318466878efd0011397d31f..b999391f4cc593de8389f030fa4179c0cd3f3ad5 100644 --- a/gxml/GomProperty.vala +++ b/gxml/GomProperty.vala @@ -382,7 +382,20 @@ public class GXml.GomDate : GomBaseProperty { } set { _value = Date (); - _value.set_parse (value); + if ("-" in value) { + string[] dp = value.split ("-"); + if (dp.length == 3) { + int y = int.parse (dp[0]); + int m = int.parse (dp[1]); + int d = int.parse (dp[2]); + _value.set_dmy ((DateDay) d, (DateMonth) m, (DateYear) y); + if (!_value.valid ()) + warning (_("Invalid Date for property: "+value)); + } else + warning (_("Invalid format for Date property: "+value)); + } else { + _value.set_parse (value); + } if (!_value.valid ()) warning (_("Invalid Date for property: "+value)); } diff --git a/test/GomSerializationTest.vala b/test/GomSerializationTest.vala index 855359e24ebeab31b32b73abdd721eae79417e4b..9972808c88345ca75b012d076d0142102289088b 100644 --- a/test/GomSerializationTest.vala +++ b/test/GomSerializationTest.vala @@ -491,12 +491,14 @@ class GomSerializationTest : GXmlTest { assert (t.pay_date.get_date ().valid ()); assert (t.pay_date.value != null); assert (t.pay_date.value == "2023-03-10"); + t.pay_date.value = "2075-3-17"; + assert (t.pay_date.get_date ().valid ()); + assert (t.pay_date.value != null); + assert (t.pay_date.value == "2075-03-17"); s = t.to_string (); assert (s != null); -#if DEBUG - GLib.message ("DOC:"+s); -#endif - assert ("PayDate=\"2023-03-10\"" in s); + message (t.pay_date.value); + assert ("PayDate=\"2075-03-17\"" in s); }); Test.add_func ("/gxml/gom-serialization/read/property-date", () => { try {