summaryrefslogtreecommitdiff
path: root/lib-common/inc/Common/Format.h
blob: 0f1fa7acca69d6824c71ad8d04c286cd2f34788f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * Copyright 2017 Samsung Electronics Co., Ltd
 *
 * Licensed under the Flora License, Version 1.1 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://floralicense.org/license/
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef COMMON_FORMAT_H
#define COMMON_FORMAT_H

#include <ctime>
#include <string>
#include <tizen.h>
#include "Utils/Range.h"

namespace Common
{
	/**
	 * @return Translatable weekday names.
	 */
	EXPORT_API Utils::Range<const char **> getWeekdayNames();

	/**
	 * @return Localized first letters of weekday names.
	 */
	EXPORT_API Utils::Range<const char **> getWeekdayLetters();

	/**
	 * @return Whether 24-hour time format is set.
	 */
	EXPORT_API bool is24HourFormat();

	/**
	 * @brief Create string representation for given time.
	 * @param[in]   time        Time to format
	 * @return Formatted time.
	 */
	EXPORT_API const char *formatTime(const tm &time);

	/**
	 * @brief Create string representation for given time with markup.
	 * @param[in]   time        Time to format
	 * @param[in]   fontSize    Font size for AM/PM representation
	 * @param[in]   fontStyle   Font style for AM/PM representation
	 * @return Formatted time.
	 */
	EXPORT_API const char *formatTime(const tm &time, int fontSize, const char *fontStyle = "Regular");

	/**
	 * @brief Create string representation for given date.
	 * @param[in]   date    Date to format
	 * @return Formatted date.
	 */
	EXPORT_API std::string formatDate(const tm &date);

	/**
	 * @brief Create string representation for given date for Screen Reader.
	 * @param[in]   date    Date to format
	 * @return Formatted date.
	 */
	EXPORT_API std::string formatVerbalDate(const tm &date);

	/**
	 * @brief Create string representation for weekly repeat mask.
	 * @param[in]   repeat  Repeat mask to format
	 * @return Formatted weekday letters with highlighted repeat.
	 */
	EXPORT_API const char *formatRepeat(int repeat);

	/**
	 * @brief Create string representation for weekly repeat mask for Screen Reader.
	 * @param[in]   repeat  Repeat mask to format
	 * @return Weekday names corresponding to repeat.
	 */
	EXPORT_API const char *formatVerbalRepeat(int repeat);

	/**
	 * @brief Create verbal description of the alarm for Screen Reader.
	 * @param[in]   date    Alarm's date
	 * @param[in]   repeat  Alarm's repeat mask
	 * @return Formatted time and repeat/date verbal description.
	 */
	EXPORT_API std::string formatVerbalDescription(const tm &date, int repeat);

	/**
	 * @brief Create "Alarm set for ... from now" message.
	 * @param[in]   date    Alarm date
	 * @return Formatted localized message.
	 */
	EXPORT_API const char *formatAlarmSetMessage(const tm &date);
}

#endif /* COMMON_FORMAT_H */