Search Results for

    Show / Hide Table of Contents

    Class Rfc822DateTimeUtil

    Provides methods for converting System.DateTime structures to and from the equivalent RFC 822 string representation.

    Inheritance
    System.Object
    Rfc822DateTimeUtil
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: ImageVault.Core.Lib.Net.Http
    Assembly: ImageVault.Core.dll
    Syntax
    public static class Rfc822DateTimeUtil
    Remarks

    Taken from http://stackoverflow.com/questions/284775/how-do-i-parse-and-convert-datetimes-to-the-rfc-822-date-time-format

    Properties

    Rfc822DateTimeFormat

    Gets the custom format specifier that may be used to represent a System.DateTime in the RFC 822 format.

    Declaration
    public static string Rfc822DateTimeFormat { get; }
    Property Value
    Type Description
    System.String

    A DateTime format string that may be used to represent a System.DateTime in the RFC 822 format.

    Remarks

    This method returns a string representation of a System.DateTime that utilizes the time zone offset (local differential) to represent the offset from Greenwich mean time in hours and minutes. The Rfc822DateTimeFormat is a valid date-time format string for use in the System.DateTime.ToString(System.String,System.IFormatProvider) method.

    The RFC 822 Date and Time specification specifies that the year will be represented as a two-digit value, but the RSS Profile recommends that all date-time values should use a four-digit year. The Rfc822DateTimeUtil class follows the RSS Profile recommendation when converting a System.DateTime to the equivalent RFC 822 string representation.

    Rfc822DateTimePatterns

    Gets an array of the expected formats for RFC 822 date-time string representations.

    Declaration
    public static string[] Rfc822DateTimePatterns { get; }
    Property Value
    Type Description
    System.String[]

    An array of the expected formats for RFC 822 date-time string representations that may used in the System.DateTime.TryParseExact(System.String,System.String[],System.IFormatProvider,System.Globalization.DateTimeStyles,System.DateTime@) method.

    Remarks

    The array of the expected formats that is returned assumes that the RFC 822 time zone is represented as or converted to a local differential representation.

    Methods

    ConvertZoneToLocalDifferential(String)

    Converts the time zone component of an RFC 822 date and time string representation to its local differential (time zone offset).

    Declaration
    public static string ConvertZoneToLocalDifferential(string s)
    Parameters
    Type Name Description
    System.String s

    A string containing an RFC 822 date and time to convert.

    Returns
    Type Description
    System.String

    A date and time string that uses local differential to describe the time zone equivalent to the date and time contained in s.

    Exceptions
    Type Condition
    System.ArgumentNullException

    s is a null reference (Nothing in Visual Basic).

    System.ArgumentNullException

    s is an empty string.

    Parse(String)

    Converts the specified string representation of a date and time to its System.DateTime equivalent.

    Declaration
    public static DateTime Parse(string s)
    Parameters
    Type Name Description
    System.String s

    A string containing a date and time to convert.

    Returns
    Type Description
    System.DateTime

    A System.DateTime equivalent to the date and time contained in s, expressed as Coordinated Universal Time (UTC).

    Remarks

    The string s is parsed using formatting information in the System.Globalization.DateTimeFormatInfo.InvariantInfo object.

    Exceptions
    Type Condition
    System.ArgumentNullException

    s is a null reference (Nothing in Visual Basic).

    System.FormatException

    s does not contain a valid RFC 822 string representation of a date and time.

    System.ArgumentNullException

    s is an empty string.

    ToString(DateTime)

    Converts the value of the specified System.DateTime object to its equivalent string representation.

    Declaration
    public static string ToString(DateTime utcDateTime)
    Parameters
    Type Name Description
    System.DateTime utcDateTime

    The Coordinated Universal Time (UTC) System.DateTime to convert.

    Returns
    Type Description
    System.String

    A RFC 822 string representation of the value of the utcDateTime.

    Exceptions
    Type Condition
    System.ArgumentException

    The specified utcDateTime object does not represent a System.DateTimeKind.Utc value.

    TryParse(String, out DateTime)

    Converts the specified string representation of a date and time to its System.DateTime equivalent.

    Declaration
    public static bool TryParse(string s, out DateTime result)
    Parameters
    Type Name Description
    System.String s

    A string containing a date and time to convert.

    System.DateTime result

    When this method returns, contains the System.DateTime value equivalent to the date and time contained in s, expressed as Coordinated Universal Time (UTC), if the conversion succeeded, or System.DateTime.MinValue if the conversion failed. The conversion fails if the s parameter is a null reference (Nothing in Visual Basic), or does not contain a valid string representation of a date and time. This parameter is passed uninitialized.

    Returns
    Type Description
    System.Boolean

    true if the s parameter was converted successfully; otherwise, false.

    Remarks

    The string s is parsed using formatting information in the System.Globalization.DateTimeFormatInfo.InvariantInfo object.

    In This Article
    Back to top (c) Meriworks 2002-2022