Skip to content

Commit 94c13d0

Browse files
tarekghsafern
andauthored
Introduce DateOnly and TimeOnly types (#50980)
Co-authored-by: Santiago Fernandez Madero <safern@microsoft.com>
1 parent 7fa839a commit 94c13d0

File tree

11 files changed

+3187
-27
lines changed

11 files changed

+3187
-27
lines changed

src/libraries/System.Private.CoreLib/src/Resources/Strings.resx

Lines changed: 57 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<root>
3-
<!--
4-
Microsoft ResX Schema
5-
3+
<!--
4+
Microsoft ResX Schema
5+
66
Version 2.0
7-
8-
The primary goals of this format is to allow a simple XML format
9-
that is mostly human readable. The generation and parsing of the
10-
various data types are done through the TypeConverter classes
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
1111
associated with the data types.
12-
12+
1313
Example:
14-
14+
1515
... ado.net/XML headers & schema ...
1616
<resheader name="resmimetype">text/microsoft-resx</resheader>
1717
<resheader name="version">2.0</resheader>
@@ -26,36 +26,36 @@
2626
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
2727
<comment>This is a comment</comment>
2828
</data>
29-
30-
There are any number of "resheader" rows that contain simple
29+
30+
There are any number of "resheader" rows that contain simple
3131
name/value pairs.
32-
33-
Each data row contains a name, and value. The row also contains a
34-
type or mimetype. Type corresponds to a .NET class that support
35-
text/value conversion through the TypeConverter architecture.
36-
Classes that don't support this are serialized and stored with the
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
3737
mimetype set.
38-
39-
The mimetype is used for serialized objects, and tells the
40-
ResXResourceReader how to depersist the object. This is currently not
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
4141
extensible. For a given mimetype the value must be set accordingly:
42-
43-
Note - application/x-microsoft.net.object.binary.base64 is the format
44-
that the ResXResourceWriter will generate, however the reader can
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
4545
read any of the formats listed below.
46-
46+
4747
mimetype: application/x-microsoft.net.object.binary.base64
48-
value : The object must be serialized with
48+
value : The object must be serialized with
4949
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
5050
: and then encoded with base64 encoding.
51-
51+
5252
mimetype: application/x-microsoft.net.object.soap.base64
53-
value : The object must be serialized with
53+
value : The object must be serialized with
5454
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
5555
: and then encoded with base64 encoding.
5656
5757
mimetype: application/x-microsoft.net.object.bytearray.base64
58-
value : The object must be serialized into a byte array
58+
value : The object must be serialized into a byte array
5959
: using a System.ComponentModel.TypeConverter
6060
: and then encoded with base64 encoding.
6161
-->
@@ -478,6 +478,14 @@
478478
<data name="Arg_MustBeChar" xml:space="preserve">
479479
<value>Object must be of type Char.</value>
480480
</data>
481+
<data name="Arg_MustBeDateOnly" xml:space="preserve">
482+
<value>Object must be of type DateOnly.</value>
483+
<comment>{Locked="DateOnly"}</comment>
484+
</data>
485+
<data name="Arg_MustBeTimeOnly" xml:space="preserve">
486+
<value>Object must be of type TimeOnly.</value>
487+
<comment>{Locked="TimeOnly"}</comment>
488+
</data>
481489
<data name="Arg_MustBeDateTime" xml:space="preserve">
482490
<value>Object must be of type DateTime.</value>
483491
</data>
@@ -1123,6 +1131,10 @@
11231131
<data name="Argument_InvalidDateTimeStyles" xml:space="preserve">
11241132
<value>An undefined DateTimeStyles value is being used.</value>
11251133
</data>
1134+
<data name="Argument_InvalidDateStyles" xml:space="preserve">
1135+
<value>The only allowed values for the styles are AllowWhiteSpaces, AllowTrailingWhite, AllowLeadingWhite, and AllowInnerWhite.</value>
1136+
<comment>{Locked="AllowWhiteSpaces, AllowTrailingWhite, AllowLeadingWhite, and AllowInnerWhite"}</comment>
1137+
</data>
11261138
<data name="Argument_InvalidDigitSubstitution" xml:space="preserve">
11271139
<value>The DigitSubstitution property must be of a valid member of the DigitShapes enumeration. Valid entries include Context, NativeNational or None.</value>
11281140
</data>
@@ -1651,6 +1663,9 @@
16511663
<data name="ArgumentOutOfRange_DateTimeBadTicks" xml:space="preserve">
16521664
<value>Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.</value>
16531665
</data>
1666+
<data name="ArgumentOutOfRange_TimeOnlyBadTicks" xml:space="preserve">
1667+
<value>Ticks must be between 0 and and TimeOnly.MaxValue.Ticks.</value>
1668+
</data>
16541669
<data name="ArgumentOutOfRange_DateTimeBadYears" xml:space="preserve">
16551670
<value>Years value must be between +/-10000.</value>
16561671
</data>
@@ -1747,6 +1762,10 @@
17471762
<data name="ArgumentOutOfRange_Month" xml:space="preserve">
17481763
<value>Month must be between one and twelve.</value>
17491764
</data>
1765+
<data name="ArgumentOutOfRange_DayNumber" xml:space="preserve">
1766+
<value>Day number must be between 0 and DateOnly.MaxValue.DayNumber.</value>
1767+
<comment>{Locked="DateOnly.MaxValue.DayNumber"}</comment>
1768+
</data>
17501769
<data name="ArgumentOutOfRange_MonthParam" xml:space="preserve">
17511770
<value>The Month parameter must be in the range 1 through 12.</value>
17521771
</data>
@@ -2173,6 +2192,17 @@
21732192
<data name="Format_BadDateTime" xml:space="preserve">
21742193
<value>String '{0}' was not recognized as a valid DateTime.</value>
21752194
</data>
2195+
<data name="Format_BadDateOnly" xml:space="preserve">
2196+
<value>String '{0}' was not recognized as a valid DateOnly.</value>
2197+
<comment>{Locked="DateOnly"}</comment>
2198+
</data>
2199+
<data name="Format_BadTimeOnly" xml:space="preserve">
2200+
<value>String '{0}' was not recognized as a valid TimeOnly.</value>
2201+
<comment>{Locked="TimeOnly"}</comment>
2202+
</data>
2203+
<data name="Format_DateTimeOnlyContainsNoneDateParts" xml:space="preserve">
2204+
<value>String '{0}' contains parts which are not specific to the {1}.</value>
2205+
</data>
21762206
<data name="Format_BadDateTimeCalendar" xml:space="preserve">
21772207
<value>The DateTime represented by the string '{0}' is not supported in calendar '{1}'.</value>
21782208
</data>

src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@
230230
<Compile Include="$(MSBuildThisFileDirectory)System\CoreLib.cs" />
231231
<Compile Include="$(MSBuildThisFileDirectory)System\CurrentSystemTimeZone.cs" />
232232
<Compile Include="$(MSBuildThisFileDirectory)System\DataMisalignedException.cs" />
233+
<Compile Include="$(MSBuildThisFileDirectory)System\DateOnly.cs" />
233234
<Compile Include="$(MSBuildThisFileDirectory)System\DateTime.cs" />
234235
<Compile Include="$(MSBuildThisFileDirectory)System\DateTimeKind.cs" />
235236
<Compile Include="$(MSBuildThisFileDirectory)System\DateTimeOffset.cs" />
@@ -1041,6 +1042,7 @@
10411042
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\WaitHandleExtensions.cs" />
10421043
<Compile Include="$(MSBuildThisFileDirectory)System\ThreadStaticAttribute.cs" />
10431044
<Compile Include="$(MSBuildThisFileDirectory)System\ThrowHelper.cs" />
1045+
<Compile Include="$(MSBuildThisFileDirectory)System\TimeOnly.cs" />
10441046
<Compile Include="$(MSBuildThisFileDirectory)System\TimeoutException.cs" />
10451047
<Compile Include="$(MSBuildThisFileDirectory)System\TimeSpan.cs" />
10461048
<Compile Include="$(MSBuildThisFileDirectory)System\TimeZone.cs" />

0 commit comments

Comments
 (0)