diff options
author | Bob Arnson <bob@firegiant.com> | 2025-07-17 22:53:40 -0400 |
---|---|---|
committer | Bob Arnson <bob@firegiant.com> | 2025-07-17 22:53:40 -0400 |
commit | f8610e59d52e5575ab1754f7a0fbb9b65908ca67 (patch) | |
tree | d64f38f8b5c62a630955a6b8ebd221385a73fd27 | |
parent | baf02e973f152ddb7d74d90f505cafc0be17c4fd (diff) | |
download | wix-bob/DateTimeErrors.tar.gz wix-bob/DateTimeErrors.tar.bz2 wix-bob/DateTimeErrors.zip |
Better date/time checking/error message.bob/DateTimeErrors
Fixes https://github.com/wixtoolset/issues/issues/9120
-rw-r--r-- | src/api/wix/WixToolset.Data/ErrorMessages.cs | 2 | ||||
-rw-r--r-- | src/wix/WixToolset.Core/CompilerCore.cs | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/api/wix/WixToolset.Data/ErrorMessages.cs b/src/api/wix/WixToolset.Data/ErrorMessages.cs index 4d986b7a..7175b0fd 100644 --- a/src/api/wix/WixToolset.Data/ErrorMessages.cs +++ b/src/api/wix/WixToolset.Data/ErrorMessages.cs | |||
@@ -1163,7 +1163,7 @@ namespace WixToolset.Data | |||
1163 | 1163 | ||
1164 | public static Message InvalidDateTimeFormat(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value) | 1164 | public static Message InvalidDateTimeFormat(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value) |
1165 | { | 1165 | { |
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); |
1167 | } | 1167 | } |
1168 | 1168 | ||
1169 | public static Message InvalidDocumentElement(SourceLineNumber sourceLineNumbers, string elementName, string fileType, string expectedElementName) | 1169 | public static Message InvalidDocumentElement(SourceLineNumber sourceLineNumbers, string elementName, string fileType, string expectedElementName) |
diff --git a/src/wix/WixToolset.Core/CompilerCore.cs b/src/wix/WixToolset.Core/CompilerCore.cs index 8d1c7e0a..57d84c3a 100644 --- a/src/wix/WixToolset.Core/CompilerCore.cs +++ b/src/wix/WixToolset.Core/CompilerCore.cs | |||
@@ -550,6 +550,11 @@ namespace WixToolset.Core | |||
550 | { | 550 | { |
551 | DateTime date = DateTime.Parse(value, CultureInfo.InvariantCulture.DateTimeFormat); | 551 | DateTime date = DateTime.Parse(value, CultureInfo.InvariantCulture.DateTimeFormat); |
552 | 552 | ||
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 | |||
553 | return ((((date.Year - 1980) * 512) + (date.Month * 32 + date.Day)) * 65536) + | 558 | return ((((date.Year - 1980) * 512) + (date.Month * 32 + date.Day)) * 65536) + |
554 | (date.Hour * 2048) + (date.Minute * 32) + (date.Second / 2); | 559 | (date.Hour * 2048) + (date.Minute * 32) + (date.Second / 2); |
555 | } | 560 | } |