18
18
import Ubuntu.Components 1.1
21
Qt Object containing a collection of useful alarm functions
23
function format_day_string(value, type) {
24
var occurs = get_day(value, type);
26
// Function to format the alarm days accordingly to their occurance
27
function format_day_string(value) {
28
var occurs = _get_day(value)
30
if (value === _get_weekdays()) {
31
return i18n.tr("Weekdays")
34
else if (value === _get_weekends()) {
35
return i18n.tr("Weekends")
38
else if (value === Alarm.Daily) {
39
return i18n.tr("Daily")
51
// Function to determine the locale's weekdays value
52
function _get_weekdays() {
26
54
for (var i = 0; i < Qt.locale().weekDays.length; ++i) {
27
55
switch (Qt.locale().weekDays[i]) {
29
WeekDay |= Alarm.Monday
32
WeekDay |= Alarm.Tuesday
35
WeekDay |= Alarm.Wednesday
38
WeekDay |= Alarm.Thursday
41
WeekDay |= Alarm.Friday
44
WeekDay |= Alarm.Saturday
47
WeekDay |= Alarm.Sunday
52
if (value == WeekDay) {
53
return i18n.tr("Every weekday")
55
else if (value == Alarm.Daily) {
56
return i18n.tr("Daily")
59
if (type === Alarm.Repeating)
60
return i18n.tr("Every ") + occurs
62
return i18n.tr("Once on ") + occurs
66
function get_day(value, type) {
68
if (value & Alarm.Monday) occurs.push(Qt.locale().standaloneDayName(1, Locale.ShortFormat));
69
if (value & Alarm.Tuesday) occurs.push(Qt.locale().standaloneDayName(2, Locale.ShortFormat));
70
if (value & Alarm.Wednesday) occurs.push(Qt.locale().standaloneDayName(3, Locale.ShortFormat));
71
if (value & Alarm.Thursday) occurs.push(Qt.locale().standaloneDayName(4, Locale.ShortFormat));
72
if (value & Alarm.Friday) occurs.push(Qt.locale().standaloneDayName(5, Locale.ShortFormat));
73
if (value & Alarm.Saturday) occurs.push(Qt.locale().standaloneDayName(6, Locale.ShortFormat));
74
if (value & Alarm.Sunday) occurs.push(Qt.locale().standaloneDayName(7, Locale.ShortFormat));
57
weekDays |= Alarm.Monday
62
weekDays |= Alarm.Tuesday
67
weekDays |= Alarm.Wednesday
72
weekDays |= Alarm.Thursday
77
weekDays |= Alarm.Friday
82
weekDays |= Alarm.Saturday
87
weekDays |= Alarm.Sunday
95
// Function to determine the locale's weekends value
96
function _get_weekends() {
97
return (Alarm.Daily - _get_weekdays())
100
// Function to retrieve the days of the week in the locale system
101
function _get_day(value) {
104
if (value & Alarm.Monday) {
105
occurs.push(Qt.locale().standaloneDayName(1, Locale.LongFormat))
108
if (value & Alarm.Tuesday) {
109
occurs.push(Qt.locale().standaloneDayName(2, Locale.LongFormat))
112
if (value & Alarm.Wednesday) {
113
occurs.push(Qt.locale().standaloneDayName(3, Locale.LongFormat))
116
if (value & Alarm.Thursday) {
117
occurs.push(Qt.locale().standaloneDayName(4, Locale.LongFormat))
120
if (value & Alarm.Friday) {
121
occurs.push(Qt.locale().standaloneDayName(5, Locale.LongFormat))
124
if (value & Alarm.Saturday) {
125
occurs.push(Qt.locale().standaloneDayName(6, Locale.LongFormat))
128
if (value & Alarm.Sunday) {
129
occurs.push(Qt.locale().standaloneDayName(0, Locale.LongFormat))
132
occurs = occurs.join(', ');