Main Content

cdflib.computeTT2000

Convert time components to CDF_TIME_TT2000 timestamp

    Description

    example

    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.

    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];
    cdflib.computeTT2000(timeVec)
    ans = int64
        31579264184000000
    

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

    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 time data into individual time components and then compute the corresponding CDF_TIME_TT2000 timestamps of the third through sixth entries.

    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
    
    
    cdflib.computeTT2000(timeArr(:,3:6))
    ans = 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