dateTimeFormat

指定 IPropertyDescription::FormatForDisplay 如何將屬性的值格式化為字串。 只有在 displayInfo displayType=「DateTime」 > 時才 < 適用。 每個displayInfo元素應該只有一個dateTimeFormat元素。

如果有多個元素,則會使用最後一個專案。 如果未提供 dateTimeFormat 元素,則會將預設屬性設定套用至屬性描述。

Syntax

      <!-- 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

 

屬性

屬性 Description
formatAs 公用。 選擇性。 預設值為 「General」。 以下是有效的值。
意義
一般 預設值。 使用 SHFormatDateTime格式化日期時間值。 使用 formatTimeAsformatDateAs 屬性來指定格式化時間和日期的方式。 需要屬性類型為 DateTime。
將值格式化為年份的其中一個月。 需要屬性類型為 Int32。 此值必須儲存為數值,其中 1 代表年份的第一個月。
YearMonth 將值格式化為 「Year - Month」。 需要屬性類型為 Int32。 值必須儲存,讓兩個最高位元組指定年份,而較低的兩個位元組則指定月份。
將值格式化為簡單的字串。

 

formatTimeAs 公用。 選擇性。 預設值為 「ShortTime」。 指定要顯示時間的格式。 當 formatAs=「General」時適用。 以下是有效的值。
意義
ShortTime 預設值。 顯示時間,例如 「7:48 PM」。
長期 顯示時間,例如 「7:48:33 PM」。
HideTime 不要顯示日期的時間部分。

 

formatDateAs 公用。 選擇性。 預設值為 「ShortDate」。 指定要顯示日期的格式。 當 formatAs=「General」時適用。 以下是有效的值。
範例
ShortDate 預設值。 顯示日期,例如 「5/13/59」。
LongDate 顯示日期,例如「星期三,1959 年 5 月 13 日」。
HideDate 不要顯示日期部分。
RelativeShortDate 盡可能顯示 「ShortDate」 之類的日期,但使用相對描述,例如「昨天」。
RelativeLongDate 盡可能顯示日期,例如 「LongDate」,但使用相對描述,例如「昨天」。