# ai_date.cpp

Go to the documentation of this file.

    00001 /* $Id: ai_date.cpp 15060 2009-01-13 15:44:36Z smatz $ */
    00002
    00005 #include "ai_date.hpp"
    00006 #include "../../date_func.h"
    00007
    00008 /* static */ int32 AIDate::GetCurrentDate()
    00009 {
    00010   return ::_date;
    00011 }
    00012
    00013 /* static */ int32 AIDate::GetYear(int32 date)
    00014 {
    00015   if (date < 0) return -1;
    00016
    00017   ::YearMonthDay ymd;
    00018 	::ConvertDateToYMD(date, &ymd);
    00019   return ymd.year;
    00020 }
    00021
    00022 /* static */ int32 AIDate::GetMonth(int32 date)
    00023 {
    00024   if (date < 0) return -1;
    00025
    00026   ::YearMonthDay ymd;
    00027 	::ConvertDateToYMD(date, &ymd);
    00028   return ymd.month + 1;
    00029 }
    00030
    00031 /* static */ int32 AIDate::GetDayOfMonth(int32 date)
    00032 {
    00033   if (date < 0) return -1;
    00034
    00035   ::YearMonthDay ymd;
    00036 	::ConvertDateToYMD(date, &ymd);
    00037   return ymd.day;
    00038 }
    00039
    00040 /* static */ int32 AIDate::GetDate(int32 year, int32 month, int32 day_of_month)
    00041 {
    00042   if (month < 1 || month > 12) return -1;
    00043   if (day_of_month < 1 || day_of_month > 31) return -1;
    00044   if (year < 0 || year > MAX_YEAR) return -1;
    00045
    00046   return ::ConvertYMDToDate(year, month - 1, day_of_month);
    00047 }