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

#include <DateTime.h>

Public Member Functions

 Interval ()
 Interval (const Interval &_src)
 Interval (int _days, int _milliseconds)
 Interval (int _days, int _hours, int _minutes, int _seconds, int _milliseconds=0)
 Interval (int64_t _milliseconds)
void assign (int _days, int _milliseconds)
void assign (int _days, int _hours, int _minutes, int _seconds, int _milliseconds=0)
void assign (int64_t _milliseconds)
const Intervaloperator= (const Interval &_src)
const Intervaloperator+= (const Interval &_iv)
const Intervaloperator-= (const Interval &_iv)
void decode (long &_days, int &_hours, int &_minutes, int &_seconds, int &_milliseconds) const
void decode (long &_days, long &_milliseconds) const
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 __milliseconds

Detailed Description

Definition at line 153 of file DateTime.h.

Constructor & Destructor Documentation

◆ Interval() [1/5]

Interval::Interval ( )

Definition at line 541 of file DateTime.cpp.

542{
543 __milliseconds = 0;
544}
int64_t __milliseconds
Definition DateTime.h:204

◆ Interval() [2/5]

Interval::Interval ( const Interval & _src)

Definition at line 546 of file DateTime.cpp.

547{
549}

◆ Interval() [3/5]

Interval::Interval ( int _days,
int _milliseconds )

Definition at line 551 of file DateTime.cpp.

552{
553 assign(_days, _milliseconds);
554}
void assign(int _days, int _milliseconds)
Definition DateTime.cpp:570

◆ Interval() [4/5]

Interval::Interval ( int _days,
int _hours,
int _minutes,
int _seconds,
int _milliseconds = 0 )

Definition at line 556 of file DateTime.cpp.

561{
562 assign(_days, _hours, _minutes, _seconds, _milliseconds);
563}

◆ Interval() [5/5]

Interval::Interval ( int64_t _milliseconds)

Definition at line 565 of file DateTime.cpp.

566{
567 assign(_milliseconds);
568}

Member Function Documentation

◆ assign() [1/3]

void Interval::assign ( int _days,
int _hours,
int _minutes,
int _seconds,
int _milliseconds = 0 )

Definition at line 575 of file DateTime.cpp.

580{
581 __milliseconds= (int64_t)_days * MSEC_PER_DAY
582 + (int64_t)_hours * MSEC_PER_HOUR
583 + (int64_t)_minutes * MSEC_PER_MIN
584 + _seconds * 1000
585 + _milliseconds;
586}
#define MSEC_PER_HOUR
Definition DateTime.cpp:398
#define MSEC_PER_DAY
Definition DateTime.cpp:396
#define MSEC_PER_MIN
Definition DateTime.cpp:400

◆ assign() [2/3]

void Interval::assign ( int _days,
int _milliseconds )

Definition at line 570 of file DateTime.cpp.

571{
572 __milliseconds = (int64_t)_days * MSEC_PER_DAY + _milliseconds;
573}

◆ assign() [3/3]

void Interval::assign ( int64_t _milliseconds)

Definition at line 588 of file DateTime.cpp.

589{
590 __milliseconds = _milliseconds;
591}

◆ days()

long Interval::days ( ) const

Definition at line 644 of file DateTime.cpp.

645{
646 return (long)(__milliseconds / MSEC_PER_DAY);
647}

◆ decode() [1/2]

void Interval::decode ( long & _days,
int & _hours,
int & _minutes,
int & _seconds,
int & _milliseconds ) const

Definition at line 626 of file DateTime.cpp.

630{
631 _days = (long)(__milliseconds / MSEC_PER_DAY);
632 _hours = (int)((__milliseconds % MSEC_PER_DAY) / MSEC_PER_HOUR);
633 _minutes = (int)((__milliseconds % MSEC_PER_HOUR) / MSEC_PER_MIN);
634 _seconds = (int)((__milliseconds % MSEC_PER_MIN) / 1000);
635 _milliseconds = (int)(__milliseconds % 1000);
636}

◆ decode() [2/2]

void Interval::decode ( long & _days,
long & _milliseconds ) const

Definition at line 638 of file DateTime.cpp.

639{
640 _days = (long)(__milliseconds / MSEC_PER_DAY);
641 _milliseconds = (long)(__milliseconds % MSEC_PER_DAY);
642}

◆ hour()

int Interval::hour ( ) const

Definition at line 649 of file DateTime.cpp.

650{
651 return (int)((__milliseconds % MSEC_PER_DAY) / MSEC_PER_HOUR);
652}

◆ minute()

int Interval::minute ( ) const

Definition at line 654 of file DateTime.cpp.

655{
656 return (int)((__milliseconds % MSEC_PER_HOUR) / MSEC_PER_MIN);
657}

◆ msecond()

int Interval::msecond ( ) const

Definition at line 664 of file DateTime.cpp.

665{
666 return (int)(__milliseconds % 1000);
667}

◆ 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 & _iv)

Definition at line 607 of file DateTime.cpp.

608{
610
611 return *this;
612}

◆ operator=()

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

Definition at line 593 of file DateTime.cpp.

594{
596
597 return *this;
598}

◆ second()

int Interval::second ( ) const

Definition at line 659 of file DateTime.cpp.

660{
661 return (int)((__milliseconds % MSEC_PER_MIN) / 1000);
662}

◆ toString()

String Interval::toString ( ) const

Definition at line 684 of file DateTime.cpp.

685{
686 long d;
687 int h, m, s, msec;
688 decode(d, h, m, s, msec);
689 if (__milliseconds < 0) {
690 return String::format(
691 L"-%ld %02d:%02d:%02d.%03d",
692 -d,
693 -h, -m, -s, -msec
694 );
695 }
696 else {
697 return String::format(
698 L"+%ld %02d:%02d:%02d.%03d",
699 d,
700 h, m, s, msec
701 );
702 }
703}
void decode(long &_days, int &_hours, int &_minutes, int &_seconds, int &_milliseconds) const
Definition DateTime.cpp:626

◆ totalHours()

int64_t Interval::totalHours ( ) const

Definition at line 669 of file DateTime.cpp.

670{
672}

◆ totalMilliSeconds()

int64_t Interval::totalMilliSeconds ( ) const
inline

Definition at line 116 of file DateTime.inl.

117{
118 return __milliseconds;
119}

◆ totalMinutes()

int64_t Interval::totalMinutes ( ) const

Definition at line 674 of file DateTime.cpp.

675{
677}

◆ totalSeconds()

int64_t Interval::totalSeconds ( ) const

Definition at line 679 of file DateTime.cpp.

680{
681 return __milliseconds / 1000;
682}

Member Data Documentation

◆ __milliseconds

int64_t Interval::__milliseconds
protected

Definition at line 204 of file DateTime.h.


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