diff --git a/src/utils/rumUtil.erl b/src/utils/rumUtil.erl index 07af9df..5e0dd8f 100644 --- a/src/utils/rumUtil.erl +++ b/src/utils/rumUtil.erl @@ -207,47 +207,47 @@ i3b(Num) -> end. %% last parse hour -parseRotateHourSpec([], DayOrMonth, Hour, Minute) -> - {DayOrMonth, Hour, Minute}; -parseRotateHourSpec([$H, M1, M2], DayOrMonth, Hour, _Minute) when M1 >= $0, M1 =< $9, M2 >= $0, M2 =< $9 -> +parseRotateHourSpec([], DayOrMonthF, Hour, Minute, DayOrMonthV) -> + {DayOrMonthF, Hour, Minute, DayOrMonthV}; +parseRotateHourSpec([$H, M1, M2], DayOrMonthF, Hour, _Minute, DayOrMonthV) when M1 >= $0, M1 =< $9, M2 >= $0, M2 =< $9 -> Min = list_to_integer([M1, M2]), - ?IIF(Min >= 0 andalso Min =< 59, {DayOrMonth, Hour, Min}, {error, invalid_date_spec}); -parseRotateHourSpec([$H, M], DayOrMonth, Hour, _Minute) when M >= $0, M =< $9 -> - {DayOrMonth, Hour, M - $0}; -parseRotateHourSpec(_, _DayOrMonth, _Hour, _Minute) -> + ?IIF(Min >= 0 andalso Min =< 59, {DayOrMonthF, Hour, Min, DayOrMonthV}, {error, invalid_date_spec}); +parseRotateHourSpec([$H, M], DayOrMonthF, Hour, _Minute, DayOrMonthV) when M >= $0, M =< $9 -> + {DayOrMonthF, Hour, M - $0, DayOrMonthV}; +parseRotateHourSpec(_, _DayOrMonth, _Hour, _Minute, _DayOrMonthV) -> {error, invalid_date_spec}. %% second parse day Default to 00:00:00 rotation -parseRotateDaySpec([], DayOrMonth, Hour, Minute) -> - {DayOrMonth, Hour, Minute}; -parseRotateDaySpec([$D, D1, D2 | T], DayOrMonth, _Hour, _Minute) when D1 > $0, D1 < $9, D2 > $0, D2 < $9 -> +parseRotateDaySpec([], DayOrMonthF, Hour, Minute, DayOrMonthV) -> + {DayOrMonthF, Hour, Minute, DayOrMonthV}; +parseRotateDaySpec([$D, D1, D2 | T], DayOrMonthF, _Hour, _Minute, DayOrMonthV) when D1 > $0, D1 < $9, D2 > $0, D2 < $9 -> Day = list_to_integer([D1, D2]), - ?IIF(Day >= 0 andalso Day =< 23, parseRotateHourSpec(T, DayOrMonth, Day, 0), {error, invalid_date_spec}); -parseRotateDaySpec([$D, D | T], DayOrMonth, _Hour, _Minute) when D >= $0, D =< $9 -> - parseRotateHourSpec(T, DayOrMonth, D - $0, 0); -parseRotateDaySpec(T, DayOrMonth, Hour, Minute) -> - parseRotateHourSpec(T, DayOrMonth, Hour, Minute). + ?IIF(Day >= 0 andalso Day =< 23, parseRotateHourSpec(T, DayOrMonthF, Day, 0, DayOrMonthV), {error, invalid_date_spec}); +parseRotateDaySpec([$D, D | T], DayOrMonthF, _Hour, _Minute, DayOrMonthV) when D >= $0, D =< $9 -> + parseRotateHourSpec(T, DayOrMonthF, D - $0, 0, DayOrMonthV); +parseRotateDaySpec(T, DayOrMonth, Hour, Minute, DayOrMonthV) -> + parseRotateHourSpec(T, DayOrMonth, Hour, Minute, DayOrMonthV). %% first parse date or week -parseRotateDateSpec([$$, $W, W | T], _DayOrMonth, _Hour, _Minute) when W >= $1, W =< $7 -> - parseRotateDaySpec(T, {day, W - $0}, 0, 0); -parseRotateDateSpec([$$, $M, L | T], _DayOrMonth, _Hour, _Minute) when L == $L; L == $l -> - parseRotateDaySpec(T, {date, last}, 0, 0); -parseRotateDateSpec([$$, $M, M1, M2 | T], _DayOrMonth, _Hour, _Minute) when M1 >= $0, M1 =< $9, M2 >= $0, M2 =< $9 -> +parseRotateDateSpec([$$, $W, W | T], _DayOrMonthF, _Hour, _Minute, _DayOrMonthV) when W >= $1, W =< $7 -> + parseRotateDaySpec(T, day, 0, 0, W - $0); +parseRotateDateSpec([$$, $M, L | T], _DayOrMonthF, _Hour, _Minute, DayOrMonthV) when L == $L; L == $l -> + parseRotateDaySpec(T, last, 0, 0, DayOrMonthV); +parseRotateDateSpec([$$, $M, M1, M2 | T], _DayOrMonthF, _Hour, _Minute, _DayOrMonthV) when M1 >= $0, M1 =< $9, M2 >= $0, M2 =< $9 -> Date = list_to_integer([M1, M2]), - ?IIF(Date >= 1 andalso Date =< 31, parseRotateDaySpec(T, {date, Date}, 0, 0), {error, invalid_date_spec}); -parseRotateDateSpec([$$, $M, M | T], _DayOrMonth, _Hour, _Minute) when M >= $1, M =< $9 -> - parseRotateDaySpec(T, {date, M - $0}, 0, 0); -parseRotateDateSpec([$$ | T], DayOrMonth, Hour, Minute) -> - parseRotateDaySpec(T, DayOrMonth, Hour, Minute); -parseRotateDateSpec(_, _DayOrMonth, _Hour, _Minute) -> + ?IIF(Date >= 1 andalso Date =< 31, parseRotateDaySpec(T, date, 0, 0, Date), {error, invalid_date_spec}); +parseRotateDateSpec([$$, $M, M | T], _DayOrMonthF, _Hour, _Minute, _DayOrMonthV) when M >= $1, M =< $9 -> + parseRotateDaySpec(T, date, 0, 0, M - $0); +parseRotateDateSpec([$$ | T], DayOrMonthF, Hour, Minute, DayOrMonthV) -> + parseRotateDaySpec(T, DayOrMonthF, Hour, Minute, DayOrMonthV); +parseRotateDateSpec(_, _DayOrMonthF, _Hour, _Minute, _DayOrMonthV) -> {error, invalid_date_spec}. parseRotateSpec(Spec) -> - case parseRotateDateSpec(Spec, undefined, undefined, undefined) of + case parseRotateDateSpec(Spec, undefined, undefined, undefined, undefined) of {error, _} = ErrRet -> ErrRet; - {undefined, undefined, undefined} -> + {undefined, undefined, undefined, _} -> {error, invalid_date_spec}; STuple -> {ok, STuple} @@ -267,10 +267,10 @@ calcNextRotateDt(Spec, NowDataTime) -> {Date, Time} = NowDataTime, calcNextRotate(Spec, Date, Time). -calcNextRotate(Spec, CurDate, CurTime) -> - {CurYear, CurMonth, CurDay} = CurDate, {CurHour, CurMinute, _} = CurTime, - case Spec of - {undefined, undefined, SMinute} -> +calcNextRotate({undefined, SHour, SMinute, _SMonthV}, CurDate, CurTime) -> + case SHour of + undefined -> + {CurHour, CurMinute, _} = CurTime, case CurMinute < SMinute of true -> %% rotation is this hour @@ -280,7 +280,7 @@ calcNextRotate(Spec, CurDate, CurTime) -> NexSec = rumTime:lDateTimeToSec({CurDate, {CurHour, SMinute, 0}}) + 3600, rumTime:secToLDateTime(NexSec) end; - {undefined, SHour, SMinute} -> + _ -> case CurTime < {SHour, SMinute, 0} of true -> %% rotation is this day @@ -289,76 +289,78 @@ calcNextRotate(Spec, CurDate, CurTime) -> %% rotation is next day NexSec = rumTime:lDateTimeToSec({CurDate, {SHour, SMinute, 0}}) + 86400, rumTime:secToLDateTime(NexSec) - end; - {{day, SDay}, SHour, SMinute} -> - CurWeekDay = rumTime:weekDay(CurDate), - if - CurWeekDay < SDay -> + end + end; +calcNextRotate({day, SHour, SMinute, SDay}, CurDate, CurTime) -> + CurWeekDay = rumTime:weekDay(CurDate), + if + CurWeekDay < SDay -> + %% rotation is this week + DiffDays = SDay - CurWeekDay, + NexSec = rumTime:lDateTimeToSec({CurDate, {SHour, SMinute, 0}}) + (86400 * DiffDays), + rumTime:secToLDateTime(NexSec); + CurWeekDay > SDay -> + %% rotation is next week + DiffDays = ((7 - CurWeekDay) + SDay), + NexSec = rumTime:lDateTimeToSec({CurDate, {SHour, SMinute, 0}}) + (86400 * DiffDays), + rumTime:secToLDateTime(NexSec); + true -> + case CurTime < {SHour, SMinute, 0} of + true -> %% rotation is this week - DiffDays = SDay - CurWeekDay, - NexSec = rumTime:lDateTimeToSec({CurDate, {SHour, SMinute, 0}}) + (86400 * DiffDays), - rumTime:secToLDateTime(NexSec); - CurWeekDay > SDay -> + {CurDate, {SHour, SMinute, 0}}; + _ -> %% rotation is next week - DiffDays = ((7 - CurWeekDay) + SDay), - NexSec = rumTime:lDateTimeToSec({CurDate, {SHour, SMinute, 0}}) + (86400 * DiffDays), - rumTime:secToLDateTime(NexSec); + NexSec = rumTime:lDateTimeToSec({CurDate, {SHour, SMinute, 0}}) + (86400 * 7), + rumTime:secToLDateTime(NexSec) + end + end; +calcNextRotate({last, SHour, SMinute, _SMonthV}, CurDate, CurTime) -> + {CurYear, CurMonth, CurDay} = CurDate, + CurMonthDay = rumTime:monthDay(CurYear, CurMonth), + case CurMonthDay == CurDay of + true -> + case CurTime < {SHour, SMinute, 0} of true -> - case CurTime < {SHour, SMinute, 0} of - true -> - %% rotation is this week - {CurDate, {SHour, SMinute, 0}}; - _ -> - %% rotation is next week - NexSec = rumTime:lDateTimeToSec({CurDate, {SHour, SMinute, 0}}) + (86400 * 7), - rumTime:secToLDateTime(NexSec) - end + %% rotation is this last month day + {CurDate, {SHour, SMinute, 0}}; + _ -> + %% rotation is next last month day + NexSec = rumTime:lDateTimeToSec({CurDate, {23, 59, 59}}) + 1, %% 下个月1号凌晨 + {NewNDate, _NewNTime} = rumTime:secToLDateTime(NexSec), + {NewNYear, NewNMonth, _} = NewNDate, + NewMonthDay = rumTime:monthDay(NewNYear, NewNMonth), + {{NewNYear, NewNMonth, NewMonthDay}, {SHour, SMinute, 0}} end; - {{date, last}, SHour, SMinute} -> + _ -> + %% rotation is this last month day + {{CurYear, CurMonth, CurMonthDay}, {SHour, SMinute, 0}} + end; +calcNextRotate({date, SHour, SMinute, SDate}, CurDate, CurTime) -> + {CurYear, CurMonth, CurDay} = CurDate, + if + CurDay < SDate -> + %% rotation is this month day + {{CurYear, CurMonth, SDate}, {SHour, SMinute, 0}}; + CurDay > SDate -> + %% rotation is next month day CurMonthDay = rumTime:monthDay(CurYear, CurMonth), - case CurMonthDay == CurDay of + NexSec = rumTime:lDateTimeToSec({{CurYear, CurMonth, CurMonthDay}, {23, 59, 59}}) + 1, + {NewNDate, _NewNTime} = rumTime:secToLDateTime(NexSec), + {NewNYear, NewNMonth, _} = NewNDate, + {{NewNYear, NewNMonth, SDate}, {SHour, SMinute, 0}}; + true -> + case CurTime < {SHour, SMinute, 0} of true -> - case CurTime < {SHour, SMinute, 0} of - true -> - %% rotation is this last month day - {CurDate, {SHour, SMinute, 0}}; - _ -> - %% rotation is next last month day - NexSec = rumTime:lDateTimeToSec({CurDate, {23, 59, 59}}) + 1, %% 下个月1号凌晨 - {NewNDate, _NewNTime} = rumTime:secToLDateTime(NexSec), - {NewNYear, NewNMonth, _} = NewNDate, - NewMonthDay = rumTime:monthDay(NewNYear, NewNMonth), - {{NewNYear, NewNMonth, NewMonthDay}, {SHour, SMinute, 0}} - end; - _ -> - %% rotation is this last month day - {{CurYear, CurMonth, CurMonthDay}, {SHour, SMinute, 0}} - end; - {{date, SDate}, SHour, SMinute} -> - if - CurDay < SDate -> %% rotation is this month day - {{CurYear, CurMonth, SDate}, {SHour, SMinute, 0}}; - CurDay > SDate -> + {CurDate, {SHour, SMinute, 0}}; + _ -> %% rotation is next month day CurMonthDay = rumTime:monthDay(CurYear, CurMonth), NexSec = rumTime:lDateTimeToSec({{CurYear, CurMonth, CurMonthDay}, {23, 59, 59}}) + 1, {NewNDate, _NewNTime} = rumTime:secToLDateTime(NexSec), {NewNYear, NewNMonth, _} = NewNDate, - {{NewNYear, NewNMonth, SDate}, {SHour, SMinute, 0}}; - true -> - case CurTime < {SHour, SMinute, 0} of - true -> - %% rotation is this month day - {CurDate, {SHour, SMinute, 0}}; - _ -> - %% rotation is next month day - CurMonthDay = rumTime:monthDay(CurYear, CurMonth), - NexSec = rumTime:lDateTimeToSec({{CurYear, CurMonth, CurMonthDay}, {23, 59, 59}}) + 1, - {NewNDate, _NewNTime} = rumTime:secToLDateTime(NexSec), - {NewNYear, NewNMonth, _} = NewNDate, - {{NewNYear, NewNMonth, SDate}, {SHour, SMinute, 0}} - end + {{NewNYear, NewNMonth, SDate}, {SHour, SMinute, 0}} end end. @@ -633,22 +635,22 @@ get_env(Key, Def) -> -ifdef(TEST). parse_test() -> - ?assertEqual({ok, {undefined, undefined, 0}}, rumUtil:parseRotateSpec("$H0")), - ?assertEqual({ok, {undefined, undefined, 59}}, rumUtil:parseRotateSpec("$H59")), - ?assertEqual({ok, {undefined, 0, 0}}, rumUtil:parseRotateSpec("$D0")), - ?assertEqual({ok, {undefined, 23, 0}}, rumUtil:parseRotateSpec("$D23")), - ?assertEqual({ok, {{day, 7}, 23, 0}}, rumUtil:parseRotateSpec("$W7D23")), - ?assertEqual({ok, {{day, 5}, 16, 0}}, rumUtil:parseRotateSpec("$W5D16")), - ?assertEqual({ok, {{day, 7}, 12, 30}}, rumUtil:parseRotateSpec("$W7D12H30")), - ?assertEqual({ok, {{date, 1}, 0, 0}}, rumUtil:parseRotateSpec("$M1D0")), - ?assertEqual({ok, {{date, 5}, 6, 0}}, rumUtil:parseRotateSpec("$M5D6")), - ?assertEqual({ok, {{date, 5}, 0, 0}}, rumUtil:parseRotateSpec("$M5")), - ?assertEqual({ok, {{date, 31}, 0, 0}}, rumUtil:parseRotateSpec("$M31")), - ?assertEqual({ok, {{date, 31}, 1, 0}}, rumUtil:parseRotateSpec("$M31D1")), - ?assertEqual({ok, {{date, last}, 0, 0}}, rumUtil:parseRotateSpec("$ML")), - ?assertEqual({ok, {{date, last}, 0, 0}}, rumUtil:parseRotateSpec("$Ml")), - ?assertEqual({ok, {{day, 5}, 0, 0}}, rumUtil:parseRotateSpec("$W5")), - ?assertEqual({ok, {{date, 5}, 12, 36}}, rumUtil:parseRotateSpec("$M5D12H36")), + ?assertEqual({ok, {undefined, undefined, 0, undefined}}, rumUtil:parseRotateSpec("$H0")), + ?assertEqual({ok, {undefined, undefined, 59, undefined}}, rumUtil:parseRotateSpec("$H59")), + ?assertEqual({ok, {undefined, 0, 0, undefined}}, rumUtil:parseRotateSpec("$D0")), + ?assertEqual({ok, {undefined, 23, 0, undefined}}, rumUtil:parseRotateSpec("$D23")), + ?assertEqual({ok, {day, 23, 0, 7}}, rumUtil:parseRotateSpec("$W7D23")), + ?assertEqual({ok, {day, 16, 0, 5}}, rumUtil:parseRotateSpec("$W5D16")), + ?assertEqual({ok, {day, 12, 30, 7}}, rumUtil:parseRotateSpec("$W7D12H30")), + ?assertEqual({ok, {date, 0, 0, 1}}, rumUtil:parseRotateSpec("$M1D0")), + ?assertEqual({ok, {date, 6, 0, 5}}, rumUtil:parseRotateSpec("$M5D6")), + ?assertEqual({ok, {date, 0, 0, 5}}, rumUtil:parseRotateSpec("$M5")), + ?assertEqual({ok, {date, 0, 0, 31}}, rumUtil:parseRotateSpec("$M31")), + ?assertEqual({ok, {date, 1, 0, 31}}, rumUtil:parseRotateSpec("$M31D1")), + ?assertEqual({ok, {last, 0, 0, undefined}}, rumUtil:parseRotateSpec("$ML")), + ?assertEqual({ok, {last, 0, 0, undefined}}, rumUtil:parseRotateSpec("$Ml")), + ?assertEqual({ok, {day, 0, 0, 5}}, rumUtil:parseRotateSpec("$W5")), + ?assertEqual({ok, {date, 12, 36, 5}}, rumUtil:parseRotateSpec("$M5D12H36")), ok. parse_fail_test() -> @@ -668,55 +670,55 @@ parse_fail_test() -> rotation_calculation_test() -> ?assertMatch({{2000, 1, 1}, {13, 0, 0}}, - rumUtil:calcNextRotateDt({undefined, undefined, 0}, {{2000, 1, 1}, {12, 34, 43}})), + rumUtil:calcNextRotateDt({undefined, undefined, 0, 0}, {{2000, 1, 1}, {12, 34, 43}})), ?assertMatch({{2000, 1, 1}, {12, 45, 0}}, - rumUtil:calcNextRotateDt({undefined, undefined, 45}, {{2000, 1, 1}, {12, 34, 43}})), + rumUtil:calcNextRotateDt({undefined, undefined, 45, 0}, {{2000, 1, 1}, {12, 34, 43}})), ?assertMatch({{2000, 1, 2}, {0, 0, 0}}, - rumUtil:calcNextRotateDt({undefined, undefined, 0}, {{2000, 1, 1}, {23, 45, 43}})), + rumUtil:calcNextRotateDt({undefined, undefined, 0, 0}, {{2000, 1, 1}, {23, 45, 43}})), ?assertMatch({{2000, 1, 2}, {0, 0, 0}}, - rumUtil:calcNextRotateDt({undefined, 0, 0}, {{2000, 1, 1}, {12, 34, 43}})), + rumUtil:calcNextRotateDt({undefined, 0, 0, 0}, {{2000, 1, 1}, {12, 34, 43}})), ?assertMatch({{2000, 1, 1}, {16, 0, 0}}, - rumUtil:calcNextRotateDt({undefined, 16, 0}, {{2000, 1, 1}, {12, 34, 43}})), + rumUtil:calcNextRotateDt({undefined, 16, 0, 0}, {{2000, 1, 1}, {12, 34, 43}})), ?assertMatch({{2000, 1, 2}, {12, 0, 0}}, - rumUtil:calcNextRotateDt({undefined, 12, 0}, {{2000, 1, 1}, {12, 34, 43}})), + rumUtil:calcNextRotateDt({undefined, 12, 0, 0}, {{2000, 1, 1}, {12, 34, 43}})), ?assertMatch({{2000, 2, 1}, {12, 0, 0}}, - rumUtil:calcNextRotateDt({{date, 1}, 12, 0}, {{2000, 1, 1}, {12, 34, 43}})), + rumUtil:calcNextRotateDt({date, 12, 0, 1}, {{2000, 1, 1}, {12, 34, 43}})), ?assertMatch({{2000, 2, 1}, {12, 0, 0}}, - rumUtil:calcNextRotateDt({{date, 1}, 12, 0}, {{2000, 1, 15}, {12, 34, 43}})), + rumUtil:calcNextRotateDt({date, 12, 0, 1}, {{2000, 1, 15}, {12, 34, 43}})), ?assertMatch({{2000, 2, 1}, {12, 0, 0}}, - rumUtil:calcNextRotateDt({{date, 1}, 12, 0}, {{2000, 1, 2}, {12, 34, 43}})), + rumUtil:calcNextRotateDt({date, 12, 0, 1}, {{2000, 1, 2}, {12, 34, 43}})), ?assertMatch({{2000, 2, 1}, {12, 0, 0}}, - rumUtil:calcNextRotateDt({{date, 1}, 12, 0}, {{2000, 1, 31}, {12, 34, 43}})), + rumUtil:calcNextRotateDt({date, 12, 0, 1}, {{2000, 1, 31}, {12, 34, 43}})), ?assertMatch({{2000, 1, 1}, {16, 0, 0}}, - rumUtil:calcNextRotateDt({{date, 1}, 16, 0}, {{2000, 1, 1}, {12, 34, 43}})), + rumUtil:calcNextRotateDt({date, 16, 0, 1}, {{2000, 1, 1}, {12, 34, 43}})), ?assertMatch({{2000, 1, 15}, {16, 0, 0}}, - rumUtil:calcNextRotateDt({{date, 15}, 16, 0}, {{2000, 1, 1}, {12, 34, 43}})), + rumUtil:calcNextRotateDt({date, 16, 0, 15}, {{2000, 1, 1}, {12, 34, 43}})), ?assertMatch({{2000, 1, 31}, {16, 0, 0}}, - rumUtil:calcNextRotateDt({{date, last}, 16, 0}, {{2000, 1, 1}, {12, 34, 43}})), + rumUtil:calcNextRotateDt({last, 16, 0, 0}, {{2000, 1, 1}, {12, 34, 43}})), ?assertMatch({{2000, 1, 31}, {16, 0, 0}}, - rumUtil:calcNextRotateDt({{date, last}, 16, 0}, {{2000, 1, 31}, {12, 34, 43}})), + rumUtil:calcNextRotateDt({last, 16, 0, 0}, {{2000, 1, 31}, {12, 34, 43}})), ?assertMatch({{2000, 2, 29}, {16, 0, 0}}, - rumUtil:calcNextRotateDt({{date, last}, 16, 0}, {{2000, 1, 31}, {17, 34, 43}})), + rumUtil:calcNextRotateDt({last, 16, 0, 0}, {{2000, 1, 31}, {17, 34, 43}})), ?assertMatch({{2001, 2, 28}, {16, 0, 0}}, - rumUtil:calcNextRotateDt({{date, last}, 16, 0}, {{2001, 1, 31}, {17, 34, 43}})), + rumUtil:calcNextRotateDt({last, 16, 0, 0}, {{2001, 1, 31}, {17, 34, 43}})), ?assertMatch({{2000, 1, 1}, {16, 0, 0}}, - rumUtil:calcNextRotateDt({{day, 6}, 16, 0}, {{2000, 1, 1}, {12, 34, 43}})), + rumUtil:calcNextRotateDt({day, 16, 0, 6}, {{2000, 1, 1}, {12, 34, 43}})), ?assertMatch({{2000, 1, 8}, {16, 0, 0}}, - rumUtil:calcNextRotateDt({{day, 6}, 16, 0}, {{2000, 1, 1}, {17, 34, 43}})), + rumUtil:calcNextRotateDt({day, 16, 0, 6}, {{2000, 1, 1}, {17, 34, 43}})), ?assertMatch({{2000, 1, 7}, {16, 0, 0}}, - rumUtil:calcNextRotateDt({{day, 5}, 16, 0}, {{2000, 1, 1}, {17, 34, 43}})), + rumUtil:calcNextRotateDt({day, 16, 0, 5}, {{2000, 1, 1}, {17, 34, 43}})), ?assertMatch({{2000, 1, 3}, {16, 0, 0}}, - rumUtil:calcNextRotateDt({{day, 1}, 16, 0}, {{2000, 1, 1}, {17, 34, 43}})), + rumUtil:calcNextRotateDt({day, 16, 0, 1}, {{2000, 1, 1}, {17, 34, 43}})), ?assertMatch({{2000, 1, 2}, {16, 0, 0}}, - rumUtil:calcNextRotateDt({{day, 7}, 16, 0}, {{2000, 1, 1}, {17, 34, 43}})), + rumUtil:calcNextRotateDt({day, 16, 0, 7}, {{2000, 1, 1}, {17, 34, 43}})), ?assertMatch({{2000, 1, 9}, {16, 0, 0}}, - rumUtil:calcNextRotateDt({{day, 7}, 16, 0}, {{2000, 1, 2}, {17, 34, 43}})), + rumUtil:calcNextRotateDt({day, 16, 0, 7}, {{2000, 1, 2}, {17, 34, 43}})), ?assertMatch({{2000, 2, 3}, {16, 0, 0}}, - rumUtil:calcNextRotateDt({{day, 4}, 16, 0}, {{2000, 1, 29}, {17, 34, 43}})), + rumUtil:calcNextRotateDt({day, 16, 0, 4}, {{2000, 1, 29}, {17, 34, 43}})), ?assertMatch({{2000, 1, 7}, {16, 0, 0}}, - rumUtil:calcNextRotateDt({{day, 5}, 16, 0}, {{2000, 1, 3}, {17, 34, 43}})), + rumUtil:calcNextRotateDt({day, 16, 0, 5}, {{2000, 1, 3}, {17, 34, 43}})), ?assertMatch({{2000, 1, 3}, {16, 0, 0}}, - rumUtil:calcNextRotateDt({{day, 1}, 16, 0}, {{1999, 12, 28}, {17, 34, 43}})), + rumUtil:calcNextRotateDt({day, 16, 0, 1}, {{1999, 12, 28}, {17, 34, 43}})), ok. check_trace_test() -> diff --git a/进度.md b/进度.md index f5afc09..353dc7d 100644 --- a/进度.md +++ b/进度.md @@ -15,6 +15,9 @@ # Doing +# 优化改进之处: + 日志旋转date格式转换函数修改 + io_lib:format 修改为eFmt:format # TODO