Main Content

cdflib.computeTT2000

Convert time components to CDF_TIME_TT2000 timestamp

Since R2022b

    Description

    tt2000 = cdflib.computeTT2000(timeVec) converts individual UTC-based time components to a CDF_TIME_TT2000 timestamp.

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

    • If timeVec is a matrix, then tt2000 is an integer vector whose length equals the number of columns of timeVec.

    For more information about CDF_TIME_TT2000 timestamps, see the More About section.

    example

    Examples

    collapse all

    Find the CDF_TIME_TT2000 timestamp for the beginning of the third millennium CE.

    timeVec = [2001;1;1;0;0;0;0;0;0];
    newMillennium = cdflib.computeTT2000(timeVec)
    newMillennium = int64
    
    31579264184000000
    

    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.

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

    Compute the corresponding CDF_TIME_TT2000 timestamps of the third through sixth entries.

    cdfTimestamps = cdflib.computeTT2000(timeArr(:,3:6))
    cdfTimestamps = 1x4 int64 row vector
    
       536500867284200300   536500868284200300   536500869284200300   536500870284200300
    
    

    Input Arguments

    collapse all

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

    When timeVec is a matrix, each column contains the individual time components of one particular time. 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]

    Example: [2000;1;1;0;0;0;0;0;0]

    Example: [2001 2001; 1 1; 1 1; 0 0; 0 0; 0 0; 0 0; 0 0; 0 1]

    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 computeTT2000.

    • 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