블로그는 나의 힘!
[ Programing ]/C++2023. 10. 17. 12:05


     time_t tTargetTime = time(NULL);     //!< 현재 시간.
     int32 nIntervalMonth = 0;     //!< 이전 설정 달 (기간).

     struct tm tmNow;
     localtime_s(&tmNow, &tTargetTime);
     if (before_interval_month != 0)
     {
          //!< 12월 변환 후 계산.
          int32 nConvertMonth = tmNow.tm_mon + 1;

          //!< 이전 설정 달이 1년 전이라면 날짜 계산.
          if (nConvertMonth - nIntervalMonth <= 0)
          {
               int32 nRemainMonth = nIntervalMonth - nConvertMonth;
               tmNow.tm_year -= 1;     //!< 1년 전으로 설정
               nRemainMonth = 12 - nRemainMonth;     //!< 설정 달로 설정
               tmNow.tm_mon = nRemainMonth - 1;
          }
          else
          {
               //!< 설정 달로 변경
               tmNow.tm_mon -= nIntervalMonth;
          }
     }
     int nReturnTime = ((tmNow.tm_year + 1900) * 100) + ( tmNow .tm_mon + 1);

 

'[ Programing ] > C++' 카테고리의 다른 글

C++ 콘솔 창.  (0) 2022.04.07
C++ MiniDump Review  (0) 2022.01.21
Memory Access Violation - 메모리 접근 위반.  (0) 2022.01.19
C++ malloc, new 메모리 할당의 차이점.  (0) 2021.11.25
MySQL C++ API / ODBC  (0) 2021.11.09
Posted by Mister_Q