Noda Time
Show / Hide Table of Contents

Class PeriodPattern

Represents a pattern for parsing and formatting Period values.
Since 1.0.x
Availability net45, netstandard1.3
Inheritance
Object
PeriodPattern
Implements
IPattern<Period>
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>

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 net45, netstandard1.3
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, "t" for ticks and "n" for nanoseconds. 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 net45, netstandard1.3
Declaration
public static PeriodPattern Roundtrip { get; }
Property Value
Type Description
PeriodPattern

Methods

AppendFormat(Period, StringBuilder)

Formats the given value as text according to the rules of this pattern, appending to the given System.Text.StringBuilder.
Since 2.0.x
Availability net45, netstandard1.3
Declaration
public StringBuilder AppendFormat(Period value, StringBuilder builder)
Parameters
Type Name Description
Period value The value to format.
StringBuilder builder The StringBuilder to append to.
Returns
Type Description
StringBuilder The builder passed in as builder.
Exceptions
Type Condition
ArgumentNullException builder is null.

Format(Period)

Formats the given period as text according to the rules of this pattern.
Since 1.0.x
Availability net45, netstandard1.3
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 net45, netstandard1.3
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.

Implements

IPattern<T>
In this article
Back to top Generated by DocFX