Main Content

cdflib.breakdownTT2000

Convert CDF_TIME_TT2000 timestamp to time components

    Description

    example

    timeVec = cdflib.breakdownTT2000(tt2000) decomposes a CDF_TIME_TT2000 timestamp into individual UTC-based time components.

    • If tt2000 is an integer scalar, then timeVec is a column vector.

    • If tt2000 is an n-element integer vector, then timeVec is a 9-by-n matrix.

    Examples

    collapse all

    Use cdflib.breakdownTT2000 to form the vector myTime of individual time components for J2000 (January 1, 2000, 12:00:00 Terrestrial Time) by passing int64(0) as the input.

    j2000 = int64(0);
    myTime = cdflib.breakdownTT2000(j2000)
    myTime = 9×1
    
            2000
               1
               1
              11
              58
              55
             816
               0
               0
    
    

    Report myTime as a datetime value in Coordinated Universal Time (UTC).

    myTimeCell = num2cell(myTime(1:7));
    datetime(myTimeCell{:},"TimeZone","UTCLeapSeconds")
    ans = datetime
       2000-01-01T11:58:55.816Z
    
    

    This example shows how to read CDF_TIME_TT2000 data into MATLAB in native form, and then decompose the data into individual time components.

    Find and explore CDF_TIME_TT2000 data in example CDF file.

    cdfid = cdflib.open("example_364.cdf");
    cdflib.inquire(cdfid)
    ans = struct with fields:
         encoding: 'IBMPC_ENCODING'
         majority: 'ROW_MAJOR'
           maxRec: 23
          numVars: 8
        numvAttrs: 3
        numgAttrs: 5
    
    
    varID = 7;
    cdflib.inquireVar(cdfid,varID)
    ans = struct with fields:
               name: 'tt2000'
           datatype: 'cdf_time_tt2000'
        numElements: 1
               dims: []
        recVariance: 1
        dimVariance: []
    
    
    numRecs = cdflib.getVarNumRecsWritten(cdfid,7)
    numRecs = 8
    

    Read CDF_TIME_TT2000 data in native int64 form.

    tt2000Data = int64([]);
    for i = 0:numRecs-1
        tt2000Data(i+1) = cdflib.getVarData(cdfid,varID,i);
    end

    Decompose the eight dates into their individual time components.

    cdflib.breakdownTT2000(tt2000Data)
    ans = 9×8
    
            2016        2016        2016        2016        2017        2017        2017        2017
              12          12          12          12           1           1           1           1
              31          31          31          31           1           1           1           1
              23          23          23          23           0           0           0           0
              59          59          59          59           0           0           0           0
              57          58          59          60           0           1           2           3
             100         100         100         100         100         100         100         100
             200         200         200         200         200         200         200         200
             300         300         300         300         300         300         300         300
    
    

    Input Arguments

    collapse all

    CDF_TIME_TT2000 timestamp, specified as an integer scalar or integer vector. For more information about CDF_TIME_TT2000 timestamps, see the More About section.

    Example: int64(1e18)

    Example: int64([0 -1])

    Data Types: int64

    Output Arguments

    collapse all

    Individual time components, returned as a 9-by-1 vector or a 9-by-n matrix, where n is the number of timestamps converted.

    Each column of timeVec contains the individual time components of one of the entries in tt2000. Each row of timeVec is a time component, according to this list:

    Row

    Value

    Range

    1

    Year (CE)

    [1707, 2292]

    2

    Month

    [1, 12]

    3

    Day

    [1, 31]

    4

    Hour

    [0, 23]

    5

    Minute

    [0, 59]

    6

    Second

    [0, 59] (or [0, 60] if leap second)

    7

    Millisecond

    [0, 999]

    8

    Microsecond

    [0, 999]

    9

    Nanosecond

    [0, 999]

    Data Types: double

    More About

    collapse all

    CDF_TIME_TT2000 Timestamp

    A CDF_TIME_TT2000 timestamp represents the number of nanoseconds elapsed since J2000. J2000 represents January 1, 2000, 12:00:00 Terrestrial Time (TT). TT differs slightly from Coordinated Universal Time (UTC). A TT time can be derived from a UTC time by adding n + 32.184 s to the UTC time, where n is the number of leap seconds that were added between 1960 and the UTC time. For more information, see Requirements for handling leap seconds in CDF and Leap second table.

    Tips

    • This function corresponds to the CDF library C API routine breakdownTT2000.

    • To use this function, you must be familiar with the CDF C interface. You can access the CDF documentation at the CDF website.

    Version History

    Introduced in R2022b