Ejemplo n.º 1
0
   DateTime DateTime::operator-(const DateTimeSpan& dateSpan) const
   {
      DateTime dateResult;    // Initializes status_ to valid

      // If either operand NULL, result NULL
      if (GetStatus() == null || dateSpan.GetStatus() == null)
      {
         dateResult.SetStatus(null);
         return dateResult;
      }

      // If either operand invalid, result invalid
      if (GetStatus() == invalid || dateSpan.GetStatus() == invalid)
      {
         dateResult.SetStatus(invalid);
         return dateResult;
      }

      // Compute the actual date difference by subtracting underlying dates
      dateResult = DateFromDouble(DoubleFromDate(dt_) - dateSpan.span_);

      // Validate within range
      dateResult.CheckRange();

      return dateResult;
   }
Ejemplo n.º 2
0
   String 
   MailImporter::GetInternalDate_DatePlusTimeZone(DateTime dtTime)
   {
      long minutes = Time::GetUTCRelationMinutes();

      DateTimeSpan dtSpan;
      dtSpan.SetDateTimeSpan(0, 0, minutes, 0);
      dtTime = dtTime + dtSpan;     

      String sDate = Time::GetTimeStampFromDateTime(dtTime);

      return sDate;
   }
   bool
   POP3ClientConnection::MessageCleanup_()
   {
      int iIndex = (*cur_message_).first;
      String sUID = (*cur_message_).second;

      int iDaysToKeep = GetDaysToKeep_(sUID);

      String sResponse;
      bool bDeleteMessageNow = false;

      if (iDaysToKeep == 0)
      {
         // Never delete messages
         return false;
      }
      else if (iDaysToKeep > 0)
      {
         // Check wether we should delete this UID.
         std::shared_ptr<FetchAccountUID> pUID = GetUIDList_()->GetUID(sUID);

         // Get the creation date of the UID.
         DateTime dtCreation = pUID->GetCreationDate();
         DateTime dtNow = Time::GetDateFromSystemDate(Time::GetCurrentDateTime());

         DateTimeSpan dtSpan = dtNow - dtCreation;

         if (dtSpan.GetNumberOfDays() <= iDaysToKeep)
         {
            // No, we should not delete this UID.
            return false;
         }
      }

      // Delete the message.
      sResponse.Format(_T("DELE %d"), iIndex);
      EnqueueWrite_(sResponse);

      current_state_ = StateDELESent;

      // Delete this UID from the database.
      GetUIDList_()->DeleteUID(sUID);
     

      return true;
   }
Ejemplo n.º 4
0
   DateTimeSpan DateTime::operator-(const DateTime& date) const
   {
      DateTimeSpan spanResult;

      // If either operand NULL, result NULL
      if (GetStatus() == null || date.GetStatus() == null)
      {
         spanResult.SetStatus(DateTimeSpan::null);
         return spanResult;
      }

      // If either operand invalid, result invalid
      if (GetStatus() == invalid || date.GetStatus() == invalid)
      {
         spanResult.SetStatus(DateTimeSpan::invalid);
         return spanResult;
      }

      // Return result (span can't be invalid, so don't check range)
      return DoubleFromDate(dt_) - DoubleFromDate(date.dt_);
   }
Ejemplo n.º 5
0
   DateTimeSpan DateTimeSpan::operator-(const DateTimeSpan& dateSpan)
      const
   {
      DateTimeSpan dateSpanTemp;

      // If either operand Null, result Null
      if (GetStatus() == null || dateSpan.GetStatus() == null)
      {
         dateSpanTemp.SetStatus(null);
         return dateSpanTemp;
      }

      // If either operand Invalid, result Invalid
      if (GetStatus() == invalid || dateSpan.GetStatus() == invalid)
      {
         dateSpanTemp.SetStatus(invalid);
         return dateSpanTemp;
      }

      // Subtract spans and validate within legal range
      dateSpanTemp.span_ = span_ - dateSpan.span_;
      dateSpanTemp.CheckRange();

      return dateSpanTemp;
   }
Ejemplo n.º 6
0
   DateTimeSpan DateTimeSpan::operator+(const DateTimeSpan& dateSpan)
      const
   {
      DateTimeSpan dateSpanTemp;

      // If either operand Null, result Null
      if (GetStatus() == null || dateSpan.GetStatus() == null)
      {

         dateSpanTemp.SetStatus(null);
         return dateSpanTemp;
      }

      // If either operand Invalid, result Invalid
      if (GetStatus() == invalid || dateSpan.GetStatus() == invalid)
      {
         dateSpanTemp.SetStatus(invalid);
         return dateSpanTemp;
      }

      // Add spans and validate within legal range
      dateSpanTemp.m_span = m_span + dateSpan.m_span;
      dateSpanTemp.CheckRange();

      return dateSpanTemp;
   }
   void 
   POP3ClientConnection::RetrieveReceivedDate_(std::shared_ptr<MimeHeader> pHeader)
   {
      if (!account_->GetProcessMIMEDate())
         return;

      String sReceivedHeader = pHeader->GetRawFieldValue("Received");

      DateTime dtTime = Utilities::GetDateTimeFromReceivedHeader(sReceivedHeader);

      if (dtTime.GetYear() < 1980 || dtTime.GetYear() > 2040)
         return;

      long minutes = Time::GetUTCRelationMinutes();
      DateTimeSpan dtSpan;
      dtSpan.SetDateTimeSpan(0, 0, minutes, 0);
      dtTime = dtTime + dtSpan;     

      String sDate = Time::GetTimeStampFromDateTime(dtTime);

      

      current_message_->SetCreateTime(sDate);
   }