Enumeration

NSDateComponentsFormatterZeroFormattingBehavior

Formatting constants for when values contain zeroes.

Declaration

typedef enum NSDateComponentsFormatterZeroFormattingBehavior : NSUInteger {
    ...
} NSDateComponentsFormatterZeroFormattingBehavior;

Topics

Constants

NSDateComponentsFormatterZeroFormattingBehaviorNone

No formatting behavior. This behavior prevents the dropping of zero values or adding of zeroes for padding. For example, with hours, minutes, and seconds displayed, the abbreviated value for one hour and 10 seconds is “1h 0m 10s”.

NSDateComponentsFormatterZeroFormattingBehaviorDefault

The default formatting behavior. When using positional units, this behavior drops leading zeroes but pads middle and trailing values with zeros as needed. For example, with hours, minutes, and seconds displayed, the value for one hour and 10 seconds is “1:00:10”. For all other unit styles, this behavior drops all units whose values are 0. For example, when days, hours, minutes, and seconds are allowed, the abbreviated version of one hour and 10 seconds is displayed as “1h 10s”.

NSDateComponentsFormatterZeroFormattingBehaviorDropLeading

The drop leading zeroes formatting behavior. Units whose values are 0 are dropped starting at the beginning of the sequence. Units continue to be dropped until a non-zero value is encountered. For example, when days, hours, minutes, and seconds are allowed, the abbreviated version of ten minutes is displayed as “10m 0s”.

NSDateComponentsFormatterZeroFormattingBehaviorDropMiddle

The drop middle zero units behavior. Units whose values are 0 are dropped from anywhere in the middle of a sequence. For example, when days, hours, minutes, and seconds are allowed, the abbreviated version of one hour, zero minutes, and five seconds is displayed as “0d 1h 5s”.

NSDateComponentsFormatterZeroFormattingBehaviorDropTrailing

The drop trailing zero units behavior. Units whose value is 0 are dropped starting at the end of the sequence. For example, when days, hours, minutes, and seconds are allowed, the abbreviated version of one hour is displayed as “0d 1h”.

NSDateComponentsFormatterZeroFormattingBehaviorDropAll

The drop all zero units behavior. This behavior drops all units whose values are 0. For example, when days, hours, minutes, and seconds are allowed, the abbreviated version of one hour is displayed as “1h”.

NSDateComponentsFormatterZeroFormattingBehaviorPad

The add padding zeroes behavior. This behavior pads values with zeroes as appropriate. For example, consider the value of one hour formatted using the positional and abbreviated unit styles. When days, hours, minutes, and seconds are allowed, the value is displayed as “0d 1:00:00” using the positional style, and as “0d 1h 0m 0s” using the abbreviated style.