Skip to content

Commit 8563fb1

Browse files
author
Ron Petrusha
authored
Updates for new Japanese calendar era (#1979)
* Updated for new Japanese calendar era * Fixed bad xml * Fixed link * Fixed link to VB sample * fixed examples heading
1 parent db9938f commit 8563fb1

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

xml/System.Globalization/Calendar.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3092,7 +3092,13 @@ Only the <xref:System.Globalization.JapaneseCalendar> and the <xref:System.Globa
30923092
<param name="millisecond">An integer from 0 to 999 that represents the millisecond.</param>
30933093
<summary>Returns a <see cref="T:System.DateTime" /> that is set to the specified date and time in the current era.</summary>
30943094
<returns>The <see cref="T:System.DateTime" /> that is set to the specified date and time in the current era.</returns>
3095-
<remarks>To be added.</remarks>
3095+
<remarks>
3096+
<format type="text/markdown"><![CDATA[
3097+
3098+
This method returns a date and time based on the current era of a particular calendar. For the <xref:System.Globalization.JapaneseCalendar> and <xref:System.Globalization.JapaneseLunisolarCalendar>, which support multiple eras based on the reign of the emperor, calling this method can produce an unintended date when an era changes. When instantiating a date using either of these calendars, we recommend that you call the <xref:System.Globalization.JapaneseCalendar.ToDateTime(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32)?displayProperty=nameWithType> or [JapaneseLunisolarCalendar.ToDateTime(Int32,Int32,Int32,Int32,Int32,Int32,Int32,Int32)](xref:System.Globalization.EastAsianLunisolarCalendar.ToDateTime(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32)) method and explicitly specify an era.
3099+
3100+
]]></format>
3101+
</remarks>
30963102
<exception cref="T:System.ArgumentOutOfRangeException">
30973103
<paramref name="year" /> is outside the range supported by the calendar.
30983104

xml/System.Globalization/JapaneseCalendar.xml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
> [!NOTE]
5050
> For information about using the <xref:System.Globalization.JapaneseCalendar> class and the other calendar classes in the .NET Framework, see [Working with Calendars](~/docs/standard/datetime/working-with-calendars.md).
5151
52-
The Japanese calendar recognizes one era for every emperor's reign. The current era is the Heisei era, which began in the Gregorian calendar year 1989. The era name is typically displayed before the year. For example, the Gregorian calendar year 2001 is the Japanese calendar year Heisei 13. Note that the first year of an era is called "Gannen." Therefore, the Gregorian calendar year 1989 was the Japanese calendar year Heisei Gannen.
52+
The Japanese calendar recognizes one era for every emperor's reign. The current era is the Heisei era, which began in the Gregorian calendar year 1989. The era name is typically displayed before the year. For example, the Gregorian calendar year 2001 is the Japanese calendar year Heisei 13. Note that the first year of an era is called "Gannen." Therefore, the Gregorian calendar year 1989 was the Japanese calendar year Heisei Gannen. By default, formatting operations with specified date and time format strings, such as "D", "F", and "Y", output Gannen rather than "1" in the result string.
5353
5454
[!INCLUDE[japanese-era-note](~/includes/calendar-era.md)]
5555
@@ -87,9 +87,9 @@
8787
8888
The date January 1, 2001 A.D. in the Gregorian calendar is equivalent to the first day of Ichigatsu in the year Heisei 13 in the Japanese calendar.
8989
90-
If the application is using the <xref:System.Globalization.JapaneseCalendar> class, <xref:System.DateTime.Parse%2A?displayProperty=nameWithType> recognizes the era abbreviations in front of the year. The abbreviation is either the single-character case-insensitive Latin alphabet abbreviation or the single-character Kanji abbreviation.
90+
If the <xref:System.Globalization.JapaneseCalendar> is the current calendar of the Japanese culture, <xref:System.DateTime.Parse%2A?displayProperty=nameWithType> recognizes the era abbreviations in front of the year. The abbreviation is either the single-character case-insensitive Latin alphabet abbreviation or the single-character Kanji abbreviation. xref:System.DateTime.Parse%2A?displayProperty=nameWithType> also recognizes either "1" or Gannen (元年) as the first year of an era.
9191
92-
Each <xref:System.Globalization.CultureInfo> object supports a set of calendars. The <xref:System.Globalization.CultureInfo.Calendar%2A> property returns the default calendar for the culture, and the <xref:System.Globalization.CultureInfo.OptionalCalendars%2A> property returns an array containing all the calendars supported by the culture. To change the calendar used by a <xref:System.Globalization.CultureInfo>, the application should set the <xref:System.Globalization.DateTimeFormatInfo.Calendar%2A> property of <xref:System.Globalization.CultureInfo.DateTimeFormat%2A?displayProperty=nameWithType> to a new <xref:System.Globalization.Calendar>.
92+
Each <xref:System.Globalization.CultureInfo> object supports a set of calendars. The <xref:System.Globalization.CultureInfo.Calendar%2A> property returns the default calendar for the culture, and the <xref:System.Globalization.CultureInfo.OptionalCalendars%2A> property returns an array containing all the calendars supported by the culture. To change the calendar used by a <xref:System.Globalization.CultureInfo>, set the <xref:System.Globalization.DateTimeFormatInfo.Calendar%2A?displayProperty=nameWithType> property to a new <xref:System.Globalization.Calendar>.
9393
9494
]]></format>
9595
</remarks>
@@ -1591,7 +1591,16 @@
15911591
15921592
## Remarks
15931593
The <xref:System.Globalization.JapaneseCalendar.ToDateTime%2A> method is useful because it can convert any date in the current calendar to a Gregorian calendar date. The Gregorian date can subsequently be used, for example, to compare dates in different calendars or create an equivalent date in a particular calendar.
1594-
1594+
1595+
Because the <xref:System.Globalization.JapaneseCalendar> supports multiple eras based on the reign of the emperor, you should always call this method and explicitly specify an era to avoid an unintended date and to make the intent of your code clear. The example shows how to instantiate a date that is always in the current era and one that belongs to a specified era.
1596+
1597+
## Examples
1598+
1599+
The following example instantiates two dates. The first is always the first day of the second year in the current era, while the second identifies a specific day in the Taisho era. The output from the example was produced with the Heisei era as the current era.
1600+
1601+
[!code-csharp[Specifying the era](~/samples/snippets/csharp/api/system.globalization/japanesecalendar/todatetime/program.cs)]
1602+
[!code-vb[Specifying the era](~/samples/snippets/visualbasic/api/system.globalization/japanesecalendar/todatetime/Program.vb)]
1603+
15951604
]]></format>
15961605
</remarks>
15971606
<exception cref="T:System.ArgumentOutOfRangeException">
@@ -1742,4 +1751,4 @@
17421751
</Docs>
17431752
</Member>
17441753
</Members>
1745-
</Type>
1754+
</Type>

0 commit comments

Comments
 (0)