Nucleus .Net Core CMS

FormatExtensions Class

Namespace: Nucleus.ViewFeatures
Assembly: Nucleus.ViewFeatures.dll
Extensions which format the output of various types.
FormatDate (Nullable<DateTime> value, TimeZoneInfo timezone)
Convert a DateTime from UTC to local time and output as a string in short date+short time format.
Parameters
Name Type
value System.Nullable<System.DateTime>
timezone TimeZoneInfo

Current user time zone. Use this.Context.Request.GetUserTimeZone() to use the auto-detected time zone.

FormatDate (Nullable<DateTime> value, TimeZoneInfo timezone, Boolean useLongTimeFormat)
Convert a DateTime from UTC to local time and output as a string in short date+short or long time format. The useLongTimeFormat parameter controls the time format.
Parameters
Name Type
value System.Nullable<System.DateTime>
timezone TimeZoneInfo

Current user time zone. Use this.Context.Request.GetUserTimeZone() to use the auto-detected time zone.

useLongTimeFormat Boolean

Specifies whether to use short or long time format.

FormatDate (DateTime value, TimeZoneInfo timezone)
Convert a DateTime from UTC to local time and output as a string in short date+short time format.
Parameters
Name Type
value DateTime
timezone TimeZoneInfo

Current user time zone. Use this.Context.Request.GetUserTimeZone() to use the auto-detected time zone.

FormatDate (DateTime value, TimeZoneInfo timezone, Boolean useLongTimeFormat)
Convert a DateTime from UTC to local time and output as a string in short date + short or long time format. The useLongTimeFormat parameter controls the time format.
Parameters
Name Type
value DateTime
timezone TimeZoneInfo

Current user time zone. Use this.Context.Request.GetUserTimeZone() to use the auto-detected time zone.

useLongTimeFormat Boolean

Specifies whether to use short or long time format.

FormatDate (DateTimeOffset value, TimeZoneInfo timezone)
Convert a DateTime from UTC to local time and output as a string in short date format.
Parameters
Name Type
value DateTimeOffset
timezone TimeZoneInfo

Current user time zone. Use this.Context.Request.GetUserTimeZone() to use the auto-detected time zone.

FormatTimeSpan (TimeSpan value)
Return a "friendly" string representation of a TimeSpan.
Parameters
Name Type
value TimeSpan
FormatTimeSpan (TimeSpan value, TimespanFormats format)
Return a "friendly" string representation of a TimeSpan.
Parameters
Name Type
value TimeSpan
format Nucleus.ViewFeatures.FormatExtensions.TimespanFormats

Specifies output format.

FormatTimeSpan (Nullable<TimeSpan> value)
Return a "friendly" string representation of a TimeSpan.
Parameters
Name Type
value System.Nullable<System.TimeSpan>
FormatTimeSpan (Nullable<TimeSpan> value, TimespanFormats format)
Return a "friendly" string representation of a TimeSpan.
Parameters
Name Type
value System.Nullable<System.TimeSpan>
format Nucleus.ViewFeatures.FormatExtensions.TimespanFormats

Specifies output format.