Skip to content

Commit e8e8812

Browse files
barnsonrobmen
authored andcommitted
Better date/time checking/error message.
Fixes wixtoolset/issues#9120
1 parent 323a476 commit e8e8812

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/api/wix/WixToolset.Data/ErrorMessages.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ public static Message InvalidBundleCondition(SourceLineNumber sourceLineNumbers,
11631163

11641164
public static Message InvalidDateTimeFormat(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value)
11651165
{
1166-
return Message(sourceLineNumbers, Ids.InvalidDateTimeFormat, "The {0}/@{1} attribute's value '{2}' is not a valid date/time value. A date/time value should follow the format YYYY-MM-DDTHH:mm:ss.", elementName, attributeName, value);
1166+
return Message(sourceLineNumbers, Ids.InvalidDateTimeFormat, "The {0}/@{1} attribute's value '{2}' is not a valid date/time value. A date/time value should follow the format YYYY-MM-DDTHH:mm:ss and be a valid date and time between 1980 and 2043, inclusive.", elementName, attributeName, value);
11671167
}
11681168

11691169
public static Message InvalidDocumentElement(SourceLineNumber sourceLineNumbers, string elementName, string fileType, string expectedElementName)

src/wix/WixToolset.Core/CompilerCore.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,11 @@ public int GetAttributeDateTimeValue(SourceLineNumber sourceLineNumbers, XAttrib
550550
{
551551
DateTime date = DateTime.Parse(value, CultureInfo.InvariantCulture.DateTimeFormat);
552552

553+
if (date.Year < 1980 || date.Year > 2043)
554+
{
555+
this.Write(ErrorMessages.InvalidDateTimeFormat(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value));
556+
}
557+
553558
return ((((date.Year - 1980) * 512) + (date.Month * 32 + date.Day)) * 65536) +
554559
(date.Hour * 2048) + (date.Minute * 32) + (date.Second / 2);
555560
}

0 commit comments

Comments
 (0)