TimeDifferenceConverter

Build 1501 on 14/Nov/2017  This topic last edited on: 13/Sep/2015, at 15:00

This is available in version 1.4 or newer.

The directory styles for use in both the web and windows client applications can now use the TimeDifferenceConverter which displays the amount of time between two given dates, or one date and the current time. Typically, this would be used in a directory style displaying a deadline, like the due date for a task:

      <ColStyle Name="dueDate" Width="130" Height="0" SortName="Due Date">

          <CellTemplate>

            <TextBlock Margin="2,0,2,0" >

              <TextBlock.Text>

                <MultiBinding Converter="{StaticResource TimeDifferenceConverter}">

                  <Binding Path="[task.autoEndDate]"/>

                </MultiBinding>

              </TextBlock.Text>

              <TextBlock.Background>

                <MultiBinding Converter="{StaticResource DeadlineColorConverter}">

                  <Binding Path="[task.autoEndDate]" />

                  <Binding Path="[task.status]" />

                  <Binding Path="[task.percentComplete]" />

                </MultiBinding>

              </TextBlock.Background>

            </TextBlock>

          </CellTemplate>

        </ColStyle>

This will display the amount of time before the deadline in various formats and will be blank once the deadline has passed.

If the deadline is several days in the future, the time difference will be displayed in the number of days, e.g. "2 days".

If the deadline is a day or so in the future, the time difference will be displayed in days and hours, e.g. "1 day 4 hrs 30 mins".

If the deadline is less than a day in the future, the time difference will be displayed in hours and minutes, e.g. "4 hrs 30 mins".

If the deadline is less than an hour in the future, the time difference will be displayed in minutes, e.g. "4 mins".

If the deadline is less than a minute in the future, the time difference will be displayed as "< 1 minute".