• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 #include <iostream>
16 #include <fstream>
17 #include <vector>
18 #include "generate_ics_file.h"
19 
20 namespace OHOS {
21 namespace Global {
22 namespace I18n {
23 
IcsFileWriter()24 IcsFileWriter::IcsFileWriter()
25 {
26 }
27 
~IcsFileWriter()28 IcsFileWriter::~IcsFileWriter()
29 {
30 }
31 
GenerateFile()32 std::string IcsFileWriter::GenerateFile()
33 {
34     std::string filePath = "/data/log/TR.ics";
35     std::ofstream fstream(filePath);
36     if (!fstream.is_open()) {
37         printf("file can't access.\r\n");
38         return filePath;
39     }
40     std::vector<std::string> list = {
41         "BEGIN:VCALENDAR\r\n",
42         "METHOD:PUBLISH\r\n",
43         "BEGIN:VEVENT\r\n",
44         "UID:1\r\n",
45         "DTSTART;VALUE=DATE:20220625\r\n",
46         "DTEND;VALUE=DATE:20220625\r\n",
47         "SUMMARY:Sacrifice Feast Holiday\r\n",
48         "RESOURCES;LANGUAGE=TR:Kurban Bayrami Tatili\r\n"
49         "END:VEVENT\r\n",
50         "BEGIN:VEVENT\r\n",
51         "UID:2\r\n",
52         "DTSTART;VALUE=DATE:20220626\r\n",
53         "DTEND;VALUE=DATE:20220626\r\n",
54         "SUMMARY:The Second Day of Sacrifice Feast\r\n",
55         "RESOURCES;LANGUAGE=TR:Kurban Bayrami 2. Günü\r\n"
56         "END:VEVENT\r\n",
57         "END:VCALENDAR\r\n"
58     };
59     for (size_t i = 0; i < list.size(); i++) {
60         fstream << list[i] << std::endl;
61     }
62     fstream.close();
63     return filePath;
64 }
65 
66 } // namespace I18n
67 } // namespace Global
68 } // namespace OHOS