Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cordova-plugin-local-notifications
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nabil Sadki
cordova-plugin-local-notifications
Commits
7500616d
Commit
7500616d
authored
Oct 02, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proper calculate next trigger date (Windows)
parent
55890836
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
21 deletions
+63
-21
Builder.cs
...Proxy/LocalNotificationProxy/LocalNotification/Builder.cs
+1
-1
Every.cs
...onProxy/LocalNotificationProxy/LocalNotification/Every.cs
+5
-5
Manager.cs
...Proxy/LocalNotificationProxy/LocalNotification/Manager.cs
+3
-2
Trigger.cs
...Proxy/LocalNotificationProxy/LocalNotification/Trigger.cs
+54
-13
No files found.
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Builder.cs
View file @
7500616d
...
...
@@ -69,7 +69,7 @@ namespace LocalNotificationProxy.LocalNotification
/// If there is at least one more toast variant to build.
/// </summary>
/// <returns>True if there are more toasts to build.</returns>
public
bool
HasNext
()
=>
this
.
Trigger
.
Count
>
this
.
Trigger
.
Occurrence
;
public
bool
HasNext
()
=>
this
.
Trigger
.
Count
>
=
this
.
Trigger
.
Occurrence
;
/// <summary>
/// Moves the flag to the next toast variant.
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Every.cs
View file @
7500616d
...
...
@@ -61,17 +61,17 @@ namespace LocalNotificationProxy.LocalNotification
/// <summary>
/// Converts the date time components into a datetime object.
/// </summary>
/// <param name="now">The relative date to calculate the date from.</param>
/// <returns>A datetime object</returns>
internal
DateTime
ToDateTime
()
internal
DateTime
ToDateTime
(
DateTime
now
)
{
var
p
=
this
.
ToArray
();
var
today
=
DateTime
.
Today
;
p
[
0
]
=
this
.
Minute
.
GetValueOrDefault
();
p
[
1
]
=
this
.
Hour
.
GetValueOrDefault
();
p
[
2
]
=
this
.
Day
.
GetValueOrDefault
(
today
.
Day
);
p
[
3
]
=
this
.
Month
.
GetValueOrDefault
(
today
.
Month
);
p
[
4
]
=
this
.
Year
.
GetValueOrDefault
(
today
.
Year
);
p
[
2
]
=
this
.
Day
.
GetValueOrDefault
(
now
.
Day
);
p
[
3
]
=
this
.
Month
.
GetValueOrDefault
(
now
.
Month
);
p
[
4
]
=
this
.
Year
.
GetValueOrDefault
(
now
.
Year
);
return
new
DateTime
(
p
[
4
].
Value
,
p
[
3
].
Value
,
p
[
2
].
Value
,
p
[
1
].
Value
,
p
[
0
].
Value
,
0
);
}
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Manager.cs
View file @
7500616d
...
...
@@ -52,11 +52,12 @@ namespace LocalNotificationProxy.LocalNotification
{
var
toast
=
builder
.
Build
();
if
(
toast
!
=
null
)
if
(
toast
=
=
null
)
{
ToastNotifier
.
AddToSchedule
(
toast
)
;
break
;
}
ToastNotifier
.
AddToSchedule
(
toast
);
builder
.
MoveNext
();
}
while
(
builder
.
HasNext
());
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Trigger.cs
View file @
7500616d
...
...
@@ -170,9 +170,18 @@ namespace LocalNotificationProxy.LocalNotification
/// <returns>The first matching date specified by trigger.every</returns>
private
DateTime
?
GetRelDate
()
{
return
this
.
GetRelDate
(
DateTime
.
Now
);
}
/// <summary>
/// Gets the date when to trigger the notification.
/// </summary>
/// <param name="now">The relative date to calculate the date from.</param>
/// <returns>The first matching date specified by trigger.every</returns>
private
DateTime
?
GetRelDate
(
DateTime
now
)
{
var
every
=
this
.
Every
as
Every
;
var
date
=
every
.
ToDateTime
();
var
now
=
DateTime
.
Now
;
var
date
=
every
.
ToDateTime
(
now
);
if
(
date
>=
now
)
{
...
...
@@ -274,7 +283,6 @@ namespace LocalNotificationProxy.LocalNotification
/// <returns>The next valid trigger date</returns>
private
DateTime
?
GetNextTriggerDate
()
{
var
every
=
this
.
Every
is
Every
?
(
this
.
Every
as
Every
).
Interval
:
this
.
Every
;
var
date
=
this
.
triggerDate
.
Value
;
var
multiple
=
this
.
Occurrence
-
1
;
...
...
@@ -283,35 +291,68 @@ namespace LocalNotificationProxy.LocalNotification
return
date
;
}
var
every
=
this
.
Every
is
Every
?
(
this
.
Every
as
Every
).
Interval
:
this
.
Every
;
switch
(
every
)
{
case
null
:
case
""
:
return
date
;
return
null
;
case
"minute"
:
return
date
.
AddMinutes
(
multiple
*
1
);
date
=
date
.
AddMinutes
(
multiple
*
1
);
break
;
case
"hour"
:
return
date
.
AddHours
(
multiple
*
1
);
date
=
date
.
AddHours
(
multiple
*
1
);
break
;
case
"day"
:
return
date
.
AddDays
(
multiple
*
1
);
date
=
date
.
AddDays
(
multiple
*
1
);
break
;
case
"week"
:
return
date
.
AddDays
(
multiple
*
7
);
date
=
date
.
AddDays
(
multiple
*
7
);
break
;
case
"month"
:
return
date
.
AddMonths
(
multiple
*
1
);
date
=
date
.
AddMonths
(
multiple
*
1
);
break
;
case
"quarter"
:
return
date
.
AddMonths
(
multiple
*
3
);
date
=
date
.
AddMonths
(
multiple
*
3
);
break
;
case
"year"
:
return
date
.
AddYears
(
multiple
*
1
);
}
date
=
date
.
AddYears
(
multiple
*
1
);
break
;
default
:
try
{
return
date
.
AddSeconds
(
multiple
*
(
60
*
int
.
Parse
(
every
as
string
)));
var
seconds
=
int
.
Parse
(
every
as
string
);
if
(
seconds
==
0
)
{
return
null
;
}
date
=
date
.
AddSeconds
(
multiple
*
seconds
);
}
catch
{
return
null
;
}
break
;
}
if
(
this
.
Every
is
Every
)
{
return
this
.
GetRelDate
(
date
);
}
return
date
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment