DCL 4.0
Loading...
Searching...
No Matches
Interval Class Reference

#include <DateTime.h>

Public Member Functions

 Interval ()
 Interval (const Interval &src)
 Interval (int nDays, int nMilliSeconds)
 Interval (int nDays, int nHours, int nMinutes, int nSeconds, int nMilliSeconds=0)
 Interval (int64_t nTotalMilliSeconds)
void assign (int nDays, int nMilliSeconds)
void assign (int nDays, int nHours, int nMinutes, int nSeconds, int nMilliSeconds=0)
void assign (int64_t nTotalMilliSeconds)
const Intervaloperator= (const Interval &src)
const Intervaloperator+= (const Interval &iv)
const Intervaloperator-= (const Interval &iv)
void decode (long &nDays, int &nHours, int &nMinutes, int &nSeconds, int &nMilliSeconds) const
void decode (long &nDays, long &nMilliSeconds)
long days () const
int hour () const
int minute () const
int second () const
int msecond () const
int64_t totalHours () const
int64_t totalMinutes () const
int64_t totalSeconds () const
int64_t totalMilliSeconds () const
String toString () const

Protected Attributes

int64_t m_nMilliSeconds

Detailed Description

Definition at line 156 of file DateTime.h.

Constructor & Destructor Documentation

◆ Interval() [1/5]

Interval::Interval ( )

Definition at line 536 of file DateTime.cpp.

537{
538 m_nMilliSeconds = 0;
539}
int64_t m_nMilliSeconds
Definition DateTime.h:200

◆ Interval() [2/5]

Interval::Interval ( const Interval & src)

Definition at line 541 of file DateTime.cpp.

542{
544}

◆ Interval() [3/5]

Interval::Interval ( int nDays,
int nMilliSeconds )

Definition at line 546 of file DateTime.cpp.

547{
548 assign(nDays, nMilliSeconds);
549}
void assign(int nDays, int nMilliSeconds)
Definition DateTime.cpp:564

◆ Interval() [4/5]

Interval::Interval ( int nDays,
int nHours,
int nMinutes,
int nSeconds,
int nMilliSeconds = 0 )

Definition at line 551 of file DateTime.cpp.

555{
556 assign(nDays, nHours, nMinutes, nSeconds, nMilliSeconds);
557}

◆ Interval() [5/5]

Interval::Interval ( int64_t nTotalMilliSeconds)

Definition at line 559 of file DateTime.cpp.

560{
561 assign(nTotalMilliSeconds);
562}

Member Function Documentation

◆ assign() [1/3]

void Interval::assign ( int nDays,
int nHours,
int nMinutes,
int nSeconds,
int nMilliSeconds = 0 )

Definition at line 569 of file DateTime.cpp.

573{
574 m_nMilliSeconds= (int64_t)nDays * MSEC_PER_DAY
575 + (int64_t)nHours * MSEC_PER_HOUR
576 + (int64_t)nMinutes * MSEC_PER_MIN
577 + nSeconds * 1000
578 + nMilliSeconds;
579}
#define MSEC_PER_HOUR
Definition DateTime.cpp:392
#define MSEC_PER_DAY
Definition DateTime.cpp:390
#define MSEC_PER_MIN
Definition DateTime.cpp:394

◆ assign() [2/3]

void Interval::assign ( int nDays,
int nMilliSeconds )

Definition at line 564 of file DateTime.cpp.

565{
566 m_nMilliSeconds = (int64_t)nDays * MSEC_PER_DAY + nMilliSeconds;
567}

◆ assign() [3/3]

void Interval::assign ( int64_t nTotalMilliSeconds)

Definition at line 581 of file DateTime.cpp.

582{
583 m_nMilliSeconds = nTotalMilliSeconds;
584}

◆ days()

long Interval::days ( ) const

Definition at line 637 of file DateTime.cpp.

638{
639 return (long)(m_nMilliSeconds / MSEC_PER_DAY);
640}

◆ decode() [1/2]

void Interval::decode ( long & nDays,
int & nHours,
int & nMinutes,
int & nSeconds,
int & nMilliSeconds ) const

Definition at line 619 of file DateTime.cpp.

623{
624 nDays = (long)(m_nMilliSeconds / MSEC_PER_DAY);
625 nHours = (int)((m_nMilliSeconds % MSEC_PER_DAY) / MSEC_PER_HOUR);
626 nMinutes = (int)((m_nMilliSeconds % MSEC_PER_HOUR) / MSEC_PER_MIN);
627 nSeconds = (int)((m_nMilliSeconds % MSEC_PER_MIN) / 1000);
628 nMilliSeconds = (int)(m_nMilliSeconds % 1000);
629}

◆ decode() [2/2]

void Interval::decode ( long & nDays,
long & nMilliSeconds )

Definition at line 631 of file DateTime.cpp.

632{
633 nDays = (long)(m_nMilliSeconds / MSEC_PER_DAY);
634 nMilliSeconds = (long)(m_nMilliSeconds % MSEC_PER_DAY);
635}

◆ hour()

int Interval::hour ( ) const

Definition at line 642 of file DateTime.cpp.

643{
644 return (int)((m_nMilliSeconds % MSEC_PER_DAY) / MSEC_PER_HOUR);
645}

◆ minute()

int Interval::minute ( ) const

Definition at line 647 of file DateTime.cpp.

648{
649 return (int)((m_nMilliSeconds % MSEC_PER_HOUR) / MSEC_PER_MIN);
650}

◆ msecond()

int Interval::msecond ( ) const

Definition at line 657 of file DateTime.cpp.

658{
659 return (int)(m_nMilliSeconds % 1000);
660}

◆ operator+=()

const Interval & Interval::operator+= ( const Interval & iv)

Definition at line 593 of file DateTime.cpp.

594{
596
597 return *this;
598}

◆ operator-=()

const Interval & Interval::operator-= ( const Interval & iv)

Definition at line 600 of file DateTime.cpp.

601{
603
604 return *this;
605}

◆ operator=()

const Interval & Interval::operator= ( const Interval & src)

Definition at line 586 of file DateTime.cpp.

587{
589
590 return *this;
591}

◆ second()

int Interval::second ( ) const

Definition at line 652 of file DateTime.cpp.

653{
654 return (int)((m_nMilliSeconds % MSEC_PER_MIN) / 1000);
655}

◆ toString()

String Interval::toString ( ) const

Definition at line 677 of file DateTime.cpp.

678{
679 long d;
680 int h, m, s, ms;
681 decode(d, h, m, s, ms);
682 if (m_nMilliSeconds < 0) {
683 return String::format(L"-%ld %02d:%02d:%02d.%03d",
684 -d,
685 -h, -m, -s, -ms
686 );
687 }
688 else {
689 return String::format(L"+%ld %02d:%02d:%02d.%03d",
690 d,
691 h, m, s, ms
692 );
693 }
694}
void decode(long &nDays, int &nHours, int &nMinutes, int &nSeconds, int &nMilliSeconds) const
Definition DateTime.cpp:619

◆ totalHours()

int64_t Interval::totalHours ( ) const

Definition at line 662 of file DateTime.cpp.

663{
665}

◆ totalMilliSeconds()

int64_t Interval::totalMilliSeconds ( ) const
inline

Definition at line 116 of file DateTime.inl.

117{
118 return m_nMilliSeconds;
119}

◆ totalMinutes()

int64_t Interval::totalMinutes ( ) const

Definition at line 667 of file DateTime.cpp.

668{
670}

◆ totalSeconds()

int64_t Interval::totalSeconds ( ) const

Definition at line 672 of file DateTime.cpp.

673{
674 return m_nMilliSeconds / 1000;
675}

Member Data Documentation

◆ m_nMilliSeconds

int64_t Interval::m_nMilliSeconds
protected

Definition at line 200 of file DateTime.h.


The documentation for this class was generated from the following files: