799
#ifdef NOTYETIMPLEMENTED
800
Date& Date::operator+=(const TemporalIntervalYear &rhs)
802
/* Simple one...add the years and adjust for any leaps */
803
int64_t new_years= _years;
804
new_years+= rhs._years;
805
if (new_years > DRIZZLE_MAX_YEARS_SQL)
808
* Set everything to zero. We got an overflow.
809
* @TODO Exceptions would be great here...
815
_years= (uint32_t) new_years;
816
if (_months == 2 && _days == 29 && days_in_gregorian_year_month(_years, _months) != 366)
821
Date& Date::operator-=(const TemporalIntervalYear &rhs)
823
/* Simple one...subtract the years and adjust for any leaps */
824
int64_t new_years= _years;
825
new_years-= rhs._years;
829
* Set everything to zero. We got an overflow.
830
* @TODO Exceptions would be great here...
836
_years= (uint32_t) new_years;
837
if (_months == 2 && _days == 29 && days_in_gregorian_year_month(_years, _months) != 366)
842
Date& Date::operator+=(const TemporalIntervalDayOrWeek &rhs)
844
/* Simple one...add the days */
845
int64_t julian_day= julian_day_number_from_gregorian_date(_years, _months, _days) + rhs._days;
846
gregorian_date_from_julian_day_number(julian_day, &_years, &_months, &_days);
850
Date& Date::operator-=(const TemporalIntervalDayOrWeek &rhs)
852
/* Simple one...subtract the days */
853
int64_t julian_day= julian_day_number_from_gregorian_date(_years, _months, _days) - rhs._days;
854
gregorian_date_from_julian_day_number(julian_day, &_years, &_months, &_days);
858
Date& Date::operator+=(const TemporalIntervalYearMonth &rhs)
860
/* Simple one...add the months in the period adjust */
861
int64_t period= (_years * 12) + (rhs._years * 12) + (_months - 1) + rhs._months;
862
int64_t new_years= (period / 12);
863
if (new_years > DRIZZLE_MAX_YEARS_SQL)
866
* Set everything to zero. We got an overflow.
867
* @TODO Exceptions would be great here...
873
_years= (uint32_t) new_years;
874
_months= (uint32_t) (period % 12) + 1;
876
/* Adjust day if the new month doesn't have enough days */
877
uint32_t days_in_new_month= days_in_gregorian_year_month(_years, _months);
878
if (_days > days_in_new_month)
879
_days= days_in_new_month;
883
Date& Date::operator-=(const TemporalIntervalYearMonth &rhs)
885
/* Simple one...subtract the months in the period and adjust */
886
int64_t period= (_years * 12) - (rhs._years * 12) + (_months - 1) - rhs._months;
887
int64_t new_years= (period / 12);
891
* Set everything to zero. We got an overflow.
892
* @TODO Exceptions would be great here...
898
_years= (uint32_t) (period / 12);
899
_months= (uint32_t) (period % 12) + 1;
901
/* Adjust day if the new month doesn't have enough days */
902
uint32_t days_in_new_month= days_in_gregorian_year_month(_years, _months);
903
if (_days > days_in_new_month)
904
_days= days_in_new_month;
908
Date& Date::operator+=(const TemporalIntervalDayOrLess &rhs)
911
* Convert the temporal and the interval into a number of
912
* microseconds, then add them together and convert the
913
* resulting microseconds back into a broken-down temporal
917
int64_t new_microseconds;
920
new_microseconds= _useconds + rhs._useconds;
921
extra_sec= new_microseconds / INT64_C(1000000);
922
new_microseconds= new_microseconds % INT64_C(1000000);
924
new_seconds= ((_days - 1) * 3600 * 24) + (_hours * 3600) + (_minutes * 60) + _seconds;
925
new_seconds+= (rhs._days * 3600 * 24) + (rhs._hours * 3600) + (rhs._minutes * 60) + rhs._seconds;
926
new_seconds+= extra_sec;
928
if (new_microseconds < 0)
930
new_microseconds+= INT64_C(1000000);
934
new_days= new_seconds / (3600 * 24L);
935
new_seconds-= new_days * 3600 * 24L;
939
new_seconds+= 3600 * 24L;
941
_useconds= (uint32_t) new_microseconds;
942
_seconds= (uint32_t) (new_seconds % 60);
943
_minutes= (uint32_t) ((new_seconds / 60) % 60);
944
_hours= (uint32_t) (new_seconds / 3600);
945
int64_t julian_day= julian_day_number_from_gregorian_date(_years, _months, 1) + new_days;
946
gregorian_date_from_julian_day_number(julian_day, &_years, &_months, &_days);
950
Date& Date::operator-=(const TemporalIntervalDayOrLess &rhs)
953
* Convert the temporal and the interval into a number of
954
* microseconds, then subtract them from each other and convert
955
* the resulting microseconds back into a broken-down temporal
959
int64_t new_microseconds;
962
new_microseconds= _useconds - rhs._useconds;
963
extra_sec= new_microseconds / INT64_C(1000000);
964
new_microseconds= new_microseconds % INT64_C(1000000);
966
new_seconds= ((_days - 1) * 3600 * 24) + (_hours * 3600) + (_minutes * 60) + _seconds;
967
new_seconds-= (rhs._days * 3600 * 24) + (rhs._hours * 3600) + (rhs._minutes * 60) + rhs._seconds;
968
new_seconds+= extra_sec;
970
if (new_microseconds < 0)
972
new_microseconds+= INT64_C(1000000);
976
new_days= new_seconds / (3600 * 24L);
977
new_seconds-= new_days * 3600 * 24L;
981
new_seconds+= 3600 * 24L;
983
_useconds= (uint32_t) new_microseconds;
984
_seconds= (uint32_t) (new_seconds % 60);
985
_minutes= (uint32_t) ((new_seconds / 60) % 60);
986
_hours= (uint32_t) (new_seconds / 3600);
987
int64_t julian_day= julian_day_number_from_gregorian_date(_years, _months, 1) + new_days;
988
gregorian_date_from_julian_day_number(julian_day, &_years, &_months, &_days);
991
#endif /* NOTYETIMPLEMENTED */
993
798
* Comparison operators between a Date and a Timestamp