Session 18: Standard clocks

Preparation

  • There are no external assets required for this training session.

Description

Standard clocks in Swift automatically take system time from the render machine.

Session specific objectives

Using clocks

Chapter 1: Adding a clock node

  • Setting the font
  • Using clock formats to format the clock time

Chapter 2: Adding offsets for different regions

  • Adding an offset using an input

Chapter 2: Countdown and count-up clocks for less than 24 hours

  • Absolute clocks
  • Supplied time calculations
  • Start time and end times

Expected duration

15 minutes

User Level

All new users

Clock format syntax

The new format uses % to specify elements.

Numbers can be padded out by adding a letter followed by a number.

 

Modifiers

U - uppercase variation of day and month names

L - lowercase variation of day and month names

% - %

a - abbreviated name of day

A - name of day

b - abbreviated name of month

B - name of month

p - am/pm

P - AM/PM

o - st/nd/rd/th

O - ST/ND/RD/TH

Y - year

M - month

D - day of month

h - hour in 24 hour format

H - hour in 12 hour format

m - minute

s - second

z - millisecond

 

Preset day nomenclature

Mon, Tue, Wed, Thu, Fri, Sat, Sun

Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday

 

Preset month nomenclature

Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec

January, February, March, April, May, June, July, August, September, October, November, December

 

Examples

%UB %D%o %Y = MONTH nth YEAR

%2h:%2m:%2s = 12:02:34

%H%p %A = Time in hours + am weekday in caps

%2h:%2m:%2s:%z = Time with millisecs

 

Markup

It is possible to insert markup into the text format to adjust sizes, fonts etc.

For example:

%H%o will make the am/pm half size.

 

Offsets for time zones

Offsets for time zones can be set using the Offset Millisecs function.

There are 3,600,000 milliseconds in a hour

 

Offset example

UTC + 4 hours

3600000 x 4 = 14400000 milliseconds

 

Session Project

If you want to review Justin Avery's instructor project at this point in the course, you can download the project zip here.