Skip to content

Commit 8b36755

Browse files
committed
update button
1 parent 9f62383 commit 8b36755

File tree

13 files changed

+403
-56
lines changed

13 files changed

+403
-56
lines changed

core/Objects/Item.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ public class Objects.Item : Objects.BaseObject {
11721172
Array<short> values = new Array<short> ();
11731173
short val;
11741174

1175-
if (due.recurrency_weeks.split (",").length > 0) {
1175+
if (due.recurrency_weeks != null && due.recurrency_weeks.split (",").length > 0) {
11761176
if (due.recurrency_weeks.contains ("1")) {
11771177
val = (short) 2;
11781178
values.append_val (val);

core/Services/CalDAV/Core.vala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,7 @@ public class Services.CalDAV.Core : GLib.Object {
278278
source.sync_finished ();
279279
source.last_sync = new GLib.DateTime.now_local ().to_string ();
280280
} catch (Error e) {
281-
var error_msg = e.message ?? "Unknown error";
282-
if (error_msg.strip () == "" || error_msg == ".") {
283-
error_msg = "Connection timeout or server closed connection";
284-
}
285-
warning ("Failed to sync: %s", error_msg);
281+
warning ("Failed to sync: %s", e.message);
286282
source.sync_failed ();
287283
}
288284
}

core/Services/Chrono/Locales/en/ENCasualDateParser.vala

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,16 @@ namespace Chrono {
3131

3232
switch (keyword) {
3333
case "now":
34-
case "today":
3534
date = now;
3635
break;
36+
case "today":
37+
date = new DateTime.local (
38+
now.get_year (),
39+
now.get_month (),
40+
now.get_day_of_month (),
41+
0, 0, 0
42+
);
43+
break;
3744
case "tonight":
3845
date = new DateTime.local (
3946
now.get_year (),
@@ -45,13 +52,31 @@ namespace Chrono {
4552
case "tomorrow":
4653
case "tmr":
4754
case "tmrw":
48-
date = now.add_days (1);
55+
var tomorrow = now.add_days (1);
56+
date = new DateTime.local (
57+
tomorrow.get_year (),
58+
tomorrow.get_month (),
59+
tomorrow.get_day_of_month (),
60+
0, 0, 0
61+
);
4962
break;
5063
case "overmorrow":
51-
date = now.add_days (2);
64+
var overmorrow = now.add_days (2);
65+
date = new DateTime.local (
66+
overmorrow.get_year (),
67+
overmorrow.get_month (),
68+
overmorrow.get_day_of_month (),
69+
0, 0, 0
70+
);
5271
break;
5372
case "yesterday":
54-
date = now.add_days (-1);
73+
var yesterday = now.add_days (-1);
74+
date = new DateTime.local (
75+
yesterday.get_year (),
76+
yesterday.get_month (),
77+
yesterday.get_day_of_month (),
78+
0, 0, 0
79+
);
5580
break;
5681
case "lastnight":
5782
date = new DateTime.local (

core/Services/Chrono/Locales/en/ENMonthNameParser.vala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ namespace Chrono {
9797
}
9898
}
9999

100+
// Validate year - must be 4 digits or 2 digits (will be converted to 20xx)
101+
if (year < 1000 && year >= 100) {
102+
return null;
103+
}
104+
100105
var result = new ParseResult ();
101106
result.date = new DateTime.local (year, month, day, 0, 0, 0);
102107

core/Services/Chrono/Locales/en/ENRelativeDateFormatParser.vala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ namespace Chrono {
6868
}
6969

7070
private DateTime add_time_unit (DateTime date, TimeUnit unit, int amount) {
71+
DateTime result;
7172
switch (unit) {
7273
case TimeUnit.SECOND:
7374
return date.add_seconds (amount);
@@ -76,15 +77,20 @@ namespace Chrono {
7677
case TimeUnit.HOUR:
7778
return date.add_hours (amount);
7879
case TimeUnit.DAY:
79-
return date.add_days (amount);
80+
result = date.add_days (amount);
81+
return new DateTime.local (result.get_year (), result.get_month (), result.get_day_of_month (), 0, 0, 0);
8082
case TimeUnit.WEEK:
81-
return date.add_weeks (amount);
83+
result = date.add_weeks (amount);
84+
return new DateTime.local (result.get_year (), result.get_month (), result.get_day_of_month (), 0, 0, 0);
8285
case TimeUnit.MONTH:
83-
return date.add_months (amount);
86+
result = date.add_months (amount);
87+
return new DateTime.local (result.get_year (), result.get_month (), result.get_day_of_month (), 0, 0, 0);
8488
case TimeUnit.QUARTER:
85-
return date.add_months (amount * 3);
89+
result = date.add_months (amount * 3);
90+
return new DateTime.local (result.get_year (), result.get_month (), result.get_day_of_month (), 0, 0, 0);
8691
case TimeUnit.YEAR:
87-
return date.add_years (amount);
92+
result = date.add_years (amount);
93+
return new DateTime.local (result.get_year (), result.get_month (), result.get_day_of_month (), 0, 0, 0);
8894
default:
8995
return date;
9096
}

core/Utils/Datetime.vala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public class Utils.Datetime {
259259
recurrency_weeks += "6,";
260260
}
261261

262-
if (recurrency_weeks.split (",").length > 0) {
262+
if (recurrency_weeks != null && recurrency_weeks.split (",").length > 0) {
263263
recurrency_weeks.slice (0, -1);
264264
}
265265

@@ -344,6 +344,10 @@ public class Utils.Datetime {
344344
}
345345

346346
public static int get_next_day_of_week_from_recurrency_week (GLib.DateTime datetime, Objects.DueDate duedate) {
347+
if (duedate.recurrency_weeks == null || duedate.recurrency_weeks == "") {
348+
return datetime.get_day_of_week ();
349+
}
350+
347351
string[] weeks = duedate.recurrency_weeks.split (",");
348352
int day_of_week = datetime.get_day_of_week ();
349353
int index = 0;
@@ -363,6 +367,10 @@ public class Utils.Datetime {
363367
}
364368

365369
public static GLib.DateTime next_recurrency_week (GLib.DateTime datetime, Objects.DueDate duedate, bool user = false) {
370+
if (duedate.recurrency_weeks == null || duedate.recurrency_weeks == "") {
371+
return datetime.add_days (duedate.recurrency_interval * 7);
372+
}
373+
366374
string[] weeks = duedate.recurrency_weeks.split (","); // [1, 2, 3]
367375
int day_of_week = datetime.get_day_of_week (); // 2
368376
int days = 0;
@@ -397,7 +405,7 @@ public class Utils.Datetime {
397405
string returned = recurrency_type.to_friendly_string (recurrency_interval);
398406

399407
if (recurrency_type == RecurrencyType.EVERY_WEEK &&
400-
recurrency_weeks.split (",").length > 0) {
408+
recurrency_weeks != null && recurrency_weeks.split (",").length > 0) {
401409
string weeks = "";
402410
if (recurrency_weeks.contains ("1")) {
403411
weeks += _("Mo,");

0 commit comments

Comments
 (0)