Class PeriodPattern
Represents a pattern for parsing and formatting Period values.
Since 1.0.x
Availability net35-Client, PCL
Inheritance
Object
PeriodPattern
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: NodaTime.Text
Assembly: NodaTime.dll
Syntax
public sealed class PeriodPattern : IPattern<Period>
Fields
NormalizingIsoPattern
A "normalizing" pattern which abides by the ISO-8601 duration format as far as possible.
Weeks are added to the number of days (after multiplying by 7). Time units are normalized
(extending into days where necessary), and fractions of seconds are represented within the
seconds part. Unlike ISO-8601, which pattern allows for negative values within a period.
Since 1.0.x
Availability net35-Client, PCL
Declaration
[Obsolete("Use NormalizingIso for compatibility with 2.0")]
public static readonly PeriodPattern NormalizingIsoPattern
Field Value
Type | Description |
---|---|
PeriodPattern |
Remarks
Note that normalizing the period when formatting will cause an System.OverflowException
if the period contains more than System.Int64.MaxValue ticks when the
combined weeks/days/time portions are considered. Such a period could never
be useful anyway, however.
RoundtripPattern
Pattern which uses the normal ISO format for all the supported ISO
fields, but extends the time part with "s" for milliseconds and "t" for ticks.
No normalization is carried out, and a period may contain weeks as well as years, months and days.
Each element may also be negative, independently of other elements. This pattern round-trips its
values: a parse/format cycle will produce an identical period, including units.
Since 1.0.x
Availability net35-Client, PCL
Declaration
[Obsolete("Use Roundtrip for compatibility with 2.0")]
public static readonly PeriodPattern RoundtripPattern
Field Value
Type | Description |
---|---|
PeriodPattern |
Properties
NormalizingIso
A "normalizing" pattern which abides by the ISO-8601 duration format as far as possible.
Weeks are added to the number of days (after multiplying by 7). Time units are normalized
(extending into days where necessary), and fractions of seconds are represented within the
seconds part. Unlike ISO-8601, which pattern allows for negative values within a period.
Since 1.4.x
Availability net35-Client, PCL
Declaration
public static PeriodPattern NormalizingIso { get; }
Property Value
Type | Description |
---|---|
PeriodPattern |
Remarks
Note that normalizing the period when formatting will cause an System.OverflowException
if the period contains more than System.Int64.MaxValue ticks when the
combined weeks/days/time portions are considered. Such a period could never
be useful anyway, however.
Roundtrip
Pattern which uses the normal ISO format for all the supported ISO
fields, but extends the time part with "s" for milliseconds and "t" for ticks.
No normalization is carried out, and a period may contain weeks as well as years, months and days.
Each element may also be negative, independently of other elements. This pattern round-trips its
values: a parse/format cycle will produce an identical period, including units.
Since 1.4.x
Availability net35-Client, PCL
Declaration
public static PeriodPattern Roundtrip { get; }
Property Value
Type | Description |
---|---|
PeriodPattern |
Methods
Format(Period)
Formats the given period as text according to the rules of this pattern.
Since 1.0.x
Availability net35-Client, PCL
Declaration
public string Format(Period value)
Parameters
Type | Name | Description |
---|---|---|
Period | value | The period to format. |
Returns
Type | Description |
---|---|
String | The period formatted according to this pattern. |
Parse(String)
Parses the given text value according to the rules of this pattern.
Since 1.0.x
Availability net35-Client, PCL
Declaration
public ParseResult<Period> Parse(string text)
Parameters
Type | Name | Description |
---|---|---|
String | text | The text value to parse. |
Returns
Type | Description |
---|---|
ParseResult<Period> | The result of parsing, which may be successful or unsuccessful. |
Remarks
This method never throws an exception (barring a bug in Noda Time itself). Even errors such as
the argument being null are wrapped in a parse result.