// $Revision: 1.4 $ // Copyright (C) 1994, 1995 Taligent, Inc. All rights reserved. #ifndef TaligentSamples_STOCKTYPES #include "StockTypes.h" #endif #ifndef Taligent_NUMERICS #include // Included for Abs function. #endif //============================================================================== // TRangeOfDays const TRangeOfDays TRangeOfDays_kAllDays(TTime::kNegativeInfinity, TTime::kPositiveInfinity); const TRangeOfDays& TRangeOfDays::kAllDays = TRangeOfDays_kAllDays; TRangeOfDays::TRangeOfDays() : fStart(TTime::kZero), fEnd(TTime::kZero) { } TRangeOfDays::TRangeOfDays(const TRangeOfDays& source) : fStart(source.fStart), fEnd(source.fEnd) { } TRangeOfDays::TRangeOfDays(const TDays& start, const TDays& end) : fStart(start), fEnd(end) { } TRangeOfDays::~TRangeOfDays() { } TRangeOfDays& TRangeOfDays::operator=(const TRangeOfDays& source) { if (&source != this) { fStart = source.fStart; fEnd = source.fEnd; } return *this; } TStream& TRangeOfDays::operator>>=(TStream& toStream) const { ::WriteVersion(toStream, kOriginalVersion); fStart >>= toStream; fEnd >>= toStream; return toStream; } TStream& TRangeOfDays::operator<<=(TStream& fromStream) { ::ReadVersion(fromStream, kOriginalVersion, kOriginalVersion); fStart <<= fromStream; fEnd <<= fromStream; return fromStream; } const TDays& TRangeOfDays::GetStart() const { return fStart; } const TDays& TRangeOfDays::GetEnd() const { return fEnd; } TDays TRangeOfDays::GetLength() const { return ::Abs(fEnd.GetDays() - fStart.GetDays()); } void TRangeOfDays::SetStart(const TDays& start) { fStart = start; } void TRangeOfDays::SetEnd(const TDays& end) { fEnd = end; } bool TRangeOfDays::Contains(const TDays& aDate) const { return fStart.GetDays() <= aDate.GetDays() && aDate.GetDays() <= fEnd.GetDays(); }