Skip to main content
A newer version of this page is available. .

Mask Type: TimeSpan

  • 4 minutes to read

Overview

The TimeSpan mask type allows users to enter time intervals. This type supports the standard time span .Net format.

Note

Run the XtraEditors demo to try out input masks.

Types

Input masks support the following time span types:

The TextEdit.Properties.Mask property provides access to a MaskProperties class instance that specifies an input mask. Set the MaskProperties.MaskType property to TimeSpan or TimeSpanAdvancingCaret to enable the time span mask type. Use the MaskProperties.EditMask property to specify the mask expression.

Standard Masks

The table below contains input masks that correspond to the standard patterns. These patterns do not depend on culture settings.

Mask

Description

Remarks

Sample (the English (US) culture)

c

Constant Format

Matches the [-][d'.']hh':'mm':'ss['.'fffffff] pattern.

g

General Short Format

Matches the [-][d':']h':'mm':'ss[.FFFFFFF] pattern.

G

General Long Format

Matches the [-]d':'hh':'mm':'ss.fffffff pattern.

Custom Masks

Mask specifiers and modifiers in the table below allow you to create custom time span input masks. For example, the mm MM, ss SS mask expression specifies the following input mask:

Specifier/Placeholder

Description

Remarks

d

Number of whole days.

Displays a single digit in the first ten-day interval (1-9).

dd-dddddddd

Number of whole days.

Displays leading zeros.

D

Short caption for days.

d‘ in the English (US) locale.

DD

Long caption for days.

day‘ or ‘days‘ in the English (US) locale.

h

Number of whole hours.

Displays a single digit in the first ten-day interval (1-9).

hh

Number of whole hours.

Displays two digits in the first-ten interval (01-09).

H

Short caption for hours.

h‘ in the English (US) locale.

HH

Long caption for hours.

hour‘ or ‘hours‘ in the English (US) locale

m

Number of whole minutes.

Displays a single digit in the first ten-day interval (1-9).

mm

Number of whole minutes.

Displays two digits in the first-ten interval (01-09).

M

Short caption for minutes.

m‘ in the English (US) locale.

MM

Long caption for minutes.

minute‘ or ‘minutes‘ in the English (US) locale.

s

Number of whole seconds.

Displays a single digit in the first-ten interval (1-9).

ss

Number of whole seconds.

Displays two digits in the first-ten interval (01-09).

S

Short caption for seconds.

s‘ in the English (US) locale

SS

Long caption for seconds.

second‘ or ‘seconds‘ in the English (US) locale.

n

Number of whole milliseconds.

Displays a single digit in the first-ten interval (1-9).

nn

Number of whole milliseconds.

Displays two digits in the first-ten interval (01-09).

nnn

Number of whole milliseconds.

Displays leading zeros.

N

Short caption for milliseconds.

ms‘ in the English (US) locale.

NN

Long caption for milliseconds.

milliseconds‘ in the English (US) locale.

f-fffffff

Number of second fractions.

F-FFFFFFF

Number of second fractions.

Any fractional trailing zeros are not included.

Z

Short caption for fractional part of seconds.

f‘ in the English (US) locale.

ZZ

Long caption for fractional part of seconds.

fractional‘ in the English (US) locale.

[,]

Elements in square brackets are optional.

:

Time separator.

Does not depend on the culture.

.

Decimal separator.

Does not depend on the culture.

"abc", 'abc'

Quoted string. Inserts the string enclosed in single or double quotes into the edit box.

The string cannot be edited in the text editor.

%<specifier>

The ‘%’ modifier that precedes a mask specifier distinguishes the specifier from the same standard mask pattern (see above).

If a mask specifier is used without other specifiers, it can be interpreted as a standard pattern. For example, the ‘d’ specifier is interpreted as the standard short date pattern, but not a month day. Precede the specifier with the ‘%’ modifier to interpret it as a placeholder.

\<character>

The backslash modifier is the escape character.

Precede a specifier with the backslash modifier to display the specifier as a character in the edit box.

Any other characters.

Any other characters are displayed in the edit box literally.

Examples

Example 1

d'.'hh':'mm':'ss - allows users to input days, hours, minutes, and seconds. The ‘.‘ and ‘:‘ characters are separators.

Example 2

d DD 'left' - allows users to input days. Displays custom text and the ‘days‘ caption according to the culture.

End-User Capabilities

  • The Up and Down Arrow keys increase and decrease the time span value portion under the caret.
  • The mouse wheel increases and decreases the time span value portion under the caret.
  • The Left and Right Arrow keys moves the caret in the corresponding direction.
  • The Space key moves the caret to the next time span value portion.
  • The time separator key moves the caret to the next time portion.