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 公共。 自選。 預設值為 「General」。 以下是有效的值。
價值 意義
常規 違約。 使用 SHFormatDateTime格式化日期時間值。 使用 formatTimeAs 和 formatDateAs 屬性來指定時間與日期的格式。 需要屬性類型為 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」 之類的日期,但盡可能使用相對描述,例如“昨天”。