TimeSpan Format Strings

You can create a standard or custom time span format string, which consists of one or more specifiers, to define how to format time span data using Composite Formatting of strings.

Standard TimeSpan Format Strings

A standard TimeSpan format string uses a single format specifier to define the text representation of a TimeSpan value that results from a formatting operation

The following table describes the standard time span format specifiers and displays a result string produced by each format specifier. Note that the string representations of time span values typically vary by culture. See the Example section for EasyLanguage code samples.

Specifier Name Description Examples
"c" Constant (invariant) format This specifier is not culture-sensitive. It takes the form [-][d’.’]hh’:’mm’:’ss[‘.’fffffff].

(The "t" and "T" format strings produce the same results.)

TimeSpan.Zero -> 00:00:00
New TimeSpan(0, 0, 30, 0) -> 00:30:00
New TimeSpan(3, 17, 25, 30, 500) -> 3.17:25:30.5000000
"g" General short format This specifier outputs only what is needed. It is culture-sensitive and takes the form [-][d’:’]h’:’mm’:’ss[.FFFFFFF]. New TimeSpan(1, 3, 16, 50, 500) -> 1:3:16:50.5
"G" General long format This specifier always outputs days and seven fractional digits. It is culture-sensitive and takes the form [-]d’:’hh’:’mm’:’ss.fffffff. . New TimeSpan(18, 30, 0) -> 0:18:30:00.0000000
Example

The following shows the use of composite formatting.  

Import Example

Composite formatting sample print output

  1. Click on the Import Example link to import the example into TradeStation.   
  2. Go to the TradeStation platform and create a Chart window.  Use the Insert - Indicator menu sequence and Add !ex_CompositeFormatting to the chart window. Select the View > EasyLanguage Print Log to see the text output.
  3. To review or modify the example code, go to the TS Development Environment and open indicator !ex_CompositeFormatting in the EasyLanguage Editor.