17 using System.Globalization;
19 using erminas.SmartAPI.CMS.Project.ContentClasses.Elements;
20 using erminas.SmartAPI.Utils;
22 namespace erminas.SmartAPI.CMS.Project.Pages.Elements
34 private readonly DateTime BASE_DATE =
new DateTime(1899, 12, 30);
36 internal StandardFieldDate(
IProject project, XmlElement xmlElement) : base(project, xmlElement)
41 : base(project, guid, languageVariant)
45 public override void Commit()
50 var value = _value.Date ==
default(DateTime)
51 ? RQL.SESSIONKEY_PLACEHOLDER
52 : _value.Date.Subtract(BASE_DATE).Days.ToString(CultureInfo.InvariantCulture);
53 Project.ExecuteRQL(
string.Format(SAVE_VALUE, Guid.ToRQLString(), value,
60 protected override DateTime FromString(
string value)
64 return DateTime.Parse(value, CultureInfo.InvariantCulture);
65 }
catch (FormatException e)
67 throw new ArgumentException(
string.Format(
"Invalid date value: {0}", value), e);
71 protected override DateTime FromXmlNodeValue(
string value)
73 return BASE_DATE.AddDays(
int.Parse(value));
76 protected override string GetXmlNodeValue()
78 return Value ==
default(DateTime)
80 : Value.Subtract(BASE_DATE).Days.ToString(CultureInfo.InvariantCulture);
83 protected override void LoadWholeStandardField()