• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

The no-code and full-code software development tool for distributed control systems and HMI

  • Doc
  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Products
    • Automation Designer
    • HMI Designer
    • Maritime HMIs
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • Framework - Automation
  • DecomposeTimestampOperator
  • 5.0.0

DecomposeTimestampOperator Class

(Automation::DecomposeTimestampOperator)

The DecomposeTimestampOperator decomposes the input timestamp into date and time basic parts. More...

Header: #include <DecomposeTimestampOperator>
Inherits: CDPOperator<T>
  • List of all members, including inherited members

Public Functions

DecomposeTimestampOperator(const CDPPropertyBase &in)

Reimplemented Public Functions

virtual void Configure(XMLPrimitive *operatorXML) override
virtual unsigned int Process() override
  • 18 public functions inherited from CDPOperator
  • 17 public functions inherited from CDPOperatorBase
  • 49 public functions inherited from CDPBaseObject
  • 27 public functions inherited from CDP::StudioAPI::CDPNode
  • 22 public functions inherited from CDP::StudioAPI::ICDPNode

Additional Inherited Members

  • 1 public variable inherited from CDPOperatorBase
  • 1 static public member inherited from CDPBaseObject
  • 1 protected function inherited from CDP::StudioAPI::CDPNode
  • 8 protected variables inherited from CDPOperator
  • 5 protected variables inherited from CDPOperatorBase
  • 10 protected variables inherited from CDPBaseObject

Detailed Description

The DecomposeTimestampOperator decomposes the input timestamp into date and time basic parts.

Note: You can use Timestamp as input to DecomposeTimestamp to get current timestamp as date and time basic parts (instead of seconds).

Arguments

NameDescription
InTimestamp in seconds including milliseconds as decimal places of the value
UTCWhen set to true (default) output values using UTC timezone, otherwise output values using local timezone
SecSeconds (0.0-59.999999) corresponding to the input timestamp
MinMinutes (0-59) corresponding to the input timestamp
HourHours (0-23) corresponding to the input timestamp
DayDay of the month corresponding to the input timestamp
MonMonth number (1-12) corresponding to the input timestamp
YearYear (4-digit) corresponding to the input timestamp
DoWDay of the week corresponding to the input timestamp
  • 0 - Sunday
  • 1 - Monday
  • 2 - Tuesday
  • 3 - Wednesday
  • 4 - Thursday
  • 5 - Friday
  • 6 - Saturday
DoYDay of the year (0-365) corresponding to the input timestamp
DSTIs set to true when local timezone was used (UTC was set to false) and Daylight Saving Time (DST) is in effect

When operator is used inside a signal its default input is automatically tied to signal's InternalValue or previous operator's output. Its default output is automatically tied to next operator's input or to signal's Value. See also CDP Operator Usage In CDP Signals.

Actual Processing Code of the DecomposeTimestampOperator

unsigned int DecomposeTimestampOperator<double>::Process()
{
  if (!m_utc || !m_sec || !m_min || !m_hour || !m_day || !m_mon || !m_year || !m_dow || !m_doy || !m_dst )
    return STATUS_ERROR;

  double timeStamp = (double)m_input;
  int64_t t = floor(timeStamp);
  tm t_tm;
  int error;
  if ((bool)*m_utc)
    error = OSAPIGMTime(&t_tm, &t);
  else
    error = OSAPILocalTime(&t_tm, &t);

  if (error)
  {
    GetParent()->ReportConfigurationFault(this, "Input timestamp " + to_string(timeStamp) +
                                          " can not be broken into component: " + strerror(error));
    m_faultReported = true;
    return STATUS_ERROR;
  }

  *m_sec = t_tm.tm_sec + (timeStamp - t);
  *m_min = t_tm.tm_min;
  *m_hour = t_tm.tm_hour;
  *m_day = t_tm.tm_mday;
  *m_mon = t_tm.tm_mon + 1;
  *m_year = t_tm.tm_year + 1900;
  *m_dow = t_tm.tm_wday;
  *m_doy = t_tm.tm_yday;
  *m_dst = t_tm.tm_isdst;
  m_output = m_input;

  if (m_faultReported)
  {
    GetParent()->ClearConfigurationFault(this);
    m_faultReported = false;
  }
  return STATUS_OK;
}

See also Argument.

Member Function Documentation

DecomposeTimestampOperator::DecomposeTimestampOperator(const CDPPropertyBase &in)

Default constructs an instance of DecomposeTimestampOperator.

[override virtual] void DecomposeTimestampOperator::Configure(XMLPrimitive *operatorXML)

[override virtual] unsigned int DecomposeTimestampOperator::Process()

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.

Try CDP Studio for free
Why CDP Studio?

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

My account

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

© Copyright 2025 CDP Technologies. Privacy and cookie policy.

Return to top