Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class NodaTime.​Text.​PeriodPattern

Assembly: NodaTime

Inheritance: object → PeriodPattern

Implemented Interfaces

Represents a pattern for parsing and formatting <see cref="T:NodaTime.Period" /> values.

Properties

public static PeriodPattern
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.
public static PeriodPattern
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.
Remarks Note that normalizing the period when formatting will cause an <see cref="T:System.OverflowException" /> if the period contains more than <see cref="F:System.Int64.MaxValue" /> ticks when the combined weeks/days/time portions are considered. Such a period could never be useful anyway, however.

Methods

public ParseResult<​Period>
Parse​(string text)
Parses the given text value according to the rules of this pattern.
Returns The result of parsing, which may be successful or unsuccessful.
text The text value to parse.
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.
public string
Format​(Period value)
Formats the given period as text according to the rules of this pattern.
Returns The period formatted according to this pattern.
value The period to format.
AppendFormat​(Period value, System.​Text.​StringBuilder builder)
Formats the given value as text according to the rules of this pattern, appending to the given <see cref="T:System.Text.StringBuilder" /> .
Returns The builder passed in as <paramref name="builder" /> .
value The value to format.
builder The <c>StringBuilder</c> to append to.
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object