1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef BUNDLE_ACTIVE_CALENDER_H
17 #define BUNDLE_ACTIVE_CALENDER_H
18 
19 #include <cstdint>
20 
21 #include "bundle_active_constant.h"
22 
23 namespace OHOS {
24 namespace DeviceUsageStats {
25 class BundleActiveCalendar {
26 public:
27     static const int64_t ONE_SECOND_MILLISECONDS = 1000;
28     int64_t dayMilliseconds_;
29     int64_t weekMilliseconds_;
30     int64_t monthMilliseconds_;
31     int64_t yearMilliseconds_;
32     BundleActiveCalendar(const int64_t timeStamp);
BundleActiveCalendar()33     BundleActiveCalendar()
34     {
35         time_ = 0;
36         dayMilliseconds_ = ONE_DAY_TIME;
37         weekMilliseconds_ = ONE_WEEK_TIME;
38         monthMilliseconds_ = ONE_MONTH_TIME;
39         yearMilliseconds_ = ONE_YEAR_TIME;
40     }
41     void ChangeToDebug();
42     void TruncateToDay();
43     void TruncateToWeek();
44     void TruncateToMonth();
45     void TruncateToYear();
46     void IncreaseDays(const int64_t val);
47     void IncreaseWeeks(const int64_t val);
48     void IncreaseMonths(const int64_t val);
49     void IncreaseYears(const int64_t val);
50     void SetMilliseconds(const int64_t timeStamp);
51     int64_t GetMilliseconds();
52     void TruncateTo(int32_t intervalType);
53 
54 private:
55     int64_t time_;
56     bool debug_ = false;
57 };
58 }  // namespace DeviceUsageStats
59 }  // namespace OHOS
60 #endif  // BUNDLE_ACTIVE_CALENDER_H
61 
62