dateTimeFormat

指定 IPropertyDescription::FormatForDisplay 应如何将属性的值格式化为字符串。 这仅适用于 <displayInfo displayType=“DateTime”>。 每个 displayInfo 元素应只有一个 dateTimeFormat 元素。

如果有多个元素,则使用最后一个元素。 如果未提供 dateTimeFormat 元素,则默认属性设置将应用于属性说明。

语法

      <!-- dateTimeFormat -->
      <xs:element name="dateTimeFormat"  minOccurs="0" maxOccurs="1">
        <xs:complexType>
          <xs:attribute name="formatAs">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:enumeration value="General"/>
                <xs:enumeration value="Month"/>
                <xs:enumeration value="YearMonth"/>
                <xs:enumeration value="Year"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
          <xs:attribute name="formatTimeAs">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:enumeration value="ShortTime"/>
                <xs:enumeration value="LongTime"/>
                <xs:enumeration value="HideTime"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
          <xs:attribute name="formatDateAs">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:enumeration value="ShortDate"/>
                <xs:enumeration value="LongDate"/>
                <xs:enumeration value="HideDate"/>
                <xs:enumeration value="RelativeShortDate"/>
                <xs:enumeration value="RelativeLongDate"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
        </xs:complexType>
      </xs:element>

元素信息

Parent 元素 子元素
displayInfo 没有

 

属性

属性 描述
formatAs 公共。 自选。 默认值为“常规”。 以下是有效值。
价值 意义
常规 违约。 使用 SHFormatDateTime设置日期/时间值的格式。 使用 formatTimeAsformatDateAs 属性指定日期和时间的格式。 要求属性类型为 DateTime。
将值格式化为年份的月份之一。 需要属性类型为 Int32。 该值必须存储为一个数字值,其中 1 表示年份的第一个月。
YearMonth 将值的格式设置为“Year - Month”。 需要属性类型为 Int32。 必须存储该值,以便两个最高字节指定年份,而较低的两个字节指定月份。
将值的格式设置为简单字符串。

 

formatTimeAs 公共。 自选。 默认值为“ShortTime”。 指定要显示时间的格式。 当 formatAs=“General”时适用。 以下是有效值。
价值 意义
ShortTime 违约。 显示时间,如“晚上 7:48”。
长期 显示时间,如“晚上 7:48:33”。
HideTime 不显示日期的时间部分。

 

formatDateAs 公共。 自选。 默认值为“ShortDate”。 指定显示日期的格式。 当 formatAs=“General”时适用。 以下是有效值。
价值
ShortDate 违约。 显示日期,如“5/13/59”。
LongDate 显示日期,如“1959 年 5 月 13 日星期三”。
HideDate 不显示日期部分。
RelativeShortDate 显示日期(如“ShortDate”),但尽可能使用相对说明,例如“昨天”。
RelativeLongDate 显示日期(如“LongDate”),但尽可能使用相对说明,例如“昨天”。