Main Content

cdflib.breakdownTT2000

Convert CDF_TIME_TT2000 timestamp to time components

Since R2022b

    Description

    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.

    example

    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));
    myTimeCell{7} = myTimeCell{7}+myTime(8)/1e3+myTime(9)/1e6;
    j2000_utc = datetime(myTimeCell{:},"TimeZone","UTCLeapSeconds")
    j2000_utc = datetime
       2000-01-01T11:58:55.816Z
    
    

    Open the example_364.cdf CDF file and prepare to read CDF_TIME_TT2000 data.

    cdfid = cdflib.open("example_364.cdf");
    varID = 7;                                          % Contains CDF_TIME_TT2000 data
    numRecs = cdflib.getVarNumRecsWritten(cdfid,varID); % Read all records
    tt2000Data = zeros(1,numRecs,"int64");              % Preallocate array

    Read CDF_TIME_TT2000 data in native int64 form.

    for i = 0:numRecs-1
        tt2000Data(i+1) = cdflib.getVarData(cdfid,varID,i);
    end
    tt2000Data' % Display as column vector for readability
    ans = 8x1 int64 column vector
    
       536500865284200300
       536500866284200300
       536500867284200300
       536500868284200300
       536500869284200300
       536500870284200300
       536500871284200300
       536500872284200300
    
    

    Decompose the eight dates into their individual time components.

    dateMatrix = cdflib.breakdownTT2000(tt2000Data)
    dateMatrix = 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