Main Content

leapseconds

List all leap seconds supported by datetime data type

Since R2020a

Description

T = leapseconds returns a timetable containing a list of the leap seconds that the datetime data type supports. For each leap second, the timetable includes the date on which it occurred, its sign, and the cumulative number of leap seconds as of that date.

To account for leap seconds in dates and times, create a datetime array by using the datetime function, and then specify the value of the 'TimeZone' name-value pair argument as 'UTCLeapSeconds'.

example

[T,vers] = leapseconds returns the International Earth Rotation and Reference Systems Service (IERS) Bulletin C version number of the leap second data being used in MATLAB®. The IERS periodically declares new leap seconds as needed. For more information, see the IERS Bulletins.

example

Examples

collapse all

Create a timetable that lists all leap seconds that the datetime data type supports.

T = leapseconds
T=27×2 timetable
       Date        Type    CumulativeAdjustment
    ___________    ____    ____________________

    30-Jun-1972     +              1 sec       
    31-Dec-1972     +              2 sec       
    31-Dec-1973     +              3 sec       
    31-Dec-1974     +              4 sec       
    31-Dec-1975     +              5 sec       
    31-Dec-1976     +              6 sec       
    31-Dec-1977     +              7 sec       
    31-Dec-1978     +              8 sec       
    31-Dec-1979     +              9 sec       
    30-Jun-1981     +             10 sec       
    30-Jun-1982     +             11 sec       
    30-Jun-1983     +             12 sec       
    30-Jun-1985     +             13 sec       
    31-Dec-1987     +             14 sec       
    31-Dec-1989     +             15 sec       
    31-Dec-1990     +             16 sec       
      ⋮

Determine if any leap seconds were added in the year 2008.

First, create a timetable of leap seconds.

T = leapseconds
T=27×2 timetable
       Date        Type    CumulativeAdjustment
    ___________    ____    ____________________

    30-Jun-1972     +              1 sec       
    31-Dec-1972     +              2 sec       
    31-Dec-1973     +              3 sec       
    31-Dec-1974     +              4 sec       
    31-Dec-1975     +              5 sec       
    31-Dec-1976     +              6 sec       
    31-Dec-1977     +              7 sec       
    31-Dec-1978     +              8 sec       
    31-Dec-1979     +              9 sec       
    30-Jun-1981     +             10 sec       
    30-Jun-1982     +             11 sec       
    30-Jun-1983     +             12 sec       
    30-Jun-1985     +             13 sec       
    31-Dec-1987     +             14 sec       
    31-Dec-1989     +             15 sec       
    31-Dec-1990     +             16 sec       
      ⋮

Create a time range object whose start and end times cover the year 2008.

tr = timerange('2008','year')
tr = 
	timetable timerange subscript:

		Select timetable rows with times in the half-open interval:
		  Starting at, including:   01-Jan-2008 00:00:00
		  Ending at, but excluding: 01-Jan-2009 00:00:00

To return rows of T whose times are within the year 2008, index into T by using tr. When you index into a timetable, you can specify rows by row number or by their row times.

T(tr,:)
ans=1×2 timetable
       Date        Type    CumulativeAdjustment
    ___________    ____    ____________________

    31-Dec-2008     +             24 sec       

List the IERS Bulletin C version number of the leap second data being used in MATLAB.

[T,vers] = leapseconds;
vers
vers = 
67

Output Arguments

collapse all

List of leap seconds, returned as a timetable.

IERS Bulletin C version number, returned as an integer.

Version History

Introduced in R2020a

Go to top of page