A formatted string that conveys the difference in time between the current date and a date that you specify.


class CLKRelativeDateTextProvider : CLKTextProvider


You use a relative date text provider to implement timers or other relative time values in an efficient way. Instead of using multiple timeline entries to replicate a countdown timer, create a single timeline entry with a relative date text provider. When the user views the clock face, ClockKit automatically updates the relative time value in your complication, providing up-to-date time information.

When creating the formatted string, the relative date text provider creates the longest string that fits in the given space. It includes as many of the requested date elements as it can, but may truncate elements or use abbreviations as needed. The formatted string takes into account the user’s region and locale settings.

Date Format Options

When creating a CLKRelativeDateTextProvider object, you must specify which calendar units you want included in the resulting date. Only the following calendar units are supported:

All other calendar units are ignored.

The format of the relative time value is dependent on the date style you choose when creating the text provider. For a list of possible styles and examples of each, see CLKRelativeDateStyle.


Creating a Text Provider

init(date: Date, style: CLKRelativeDateStyle, units: NSCalendar.Unit)

Creates and returns a text provider with the specified date and style information.

Getting the Date Information

var date: Date

The target date to use for calculations.

var relativeDateStyle: CLKRelativeDateStyle

The formatting style to use for the relative time value.

var calendarUnits: NSCalendar.Unit

The calendar units to include in the formatted string.


enum CLKRelativeDateStyle

Constants indicating the formatting style for the relative date values.


Inherits From

Conforms To

See Also

Data Providers

class CLKDateTextProvider

A formatted string that conveys a date without any time information.

class CLKImageProvider

An image displayed by a complication.

class CLKFullColorImageProvider

A full-color image displayed by a complication.

class CLKSimpleTextProvider

A single line of text to display in your complication interface.

class CLKTextProvider

The common behavior for displaying text-based data in a complication.

class CLKTimeIntervalTextProvider

A formatted time range.

class CLKTimeTextProvider

A formatted time value.

class CLKSimpleGaugeProvider

A gauge that shows a fractional value.

class CLKTimeIntervalGaugeProvider

A gauge that tracks time intervals.

class CLKGaugeProvider

An abstract superclass that provides all the common behaviors for the gauge providers.

let CLKSimpleGaugeProviderFillFractionEmpty: Float

A fill value indicating an empty gauge.

enum CLKGaugeProviderStyle

Visual styles available for gauges.