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
dbb83bbe
Commit
dbb83bbe
authored
Sep 30, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix TODO: end of day, month, ...
parent
61e8c70b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
75 deletions
+30
-75
Every.cs
...onProxy/LocalNotificationProxy/LocalNotification/Every.cs
+13
-32
Trigger.cs
...Proxy/LocalNotificationProxy/LocalNotification/Trigger.cs
+17
-43
No files found.
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Every.cs
View file @
dbb83bbe
...
...
@@ -81,50 +81,31 @@ namespace LocalNotificationProxy.LocalNotification
/// Gets the interval as a string representation.
/// </summary>
/// <returns>year, month, ...</returns>
internal
string
Interval
{
get
{
var
pos
=
Array
.
IndexOf
(
this
.
ToArray
(),
0
);
return
Intervals
[
pos
+
1
];
}
}
/// <summary>
/// Gets an array of all date parts to construct a datetime instance.
/// </summary>
/// <returns>[min, hour, day, month, year]</returns>
internal
int
[]
ToArray
()
{
return
new
int
[]
{
this
.
Minute
,
this
.
Hour
,
this
.
Day
,
this
.
Month
,
this
.
Year
};
}
internal
string
Interval
{
get
=>
Intervals
[
Array
.
IndexOf
(
this
.
ToArray
(),
0
)
+
1
];
}
/// <summary>
///
Gets an array of all date parts to construct a datetime instance
.
///
Converts the date time components into a datetime object
.
/// </summary>
/// <returns>
[min, hour, day, month, year]
</returns>
internal
int
[]
ToArray2
()
/// <returns>
A datetime object
</returns>
internal
DateTime
ToDateTime
()
{
var
p
=
this
.
ToArray
();
var
today
=
DateTime
.
Today
;
var
ary
=
this
.
ToArray
();
ary
[
2
]
=
this
.
Day
>
0
?
this
.
Day
:
today
.
Day
;
ary
[
3
]
=
this
.
Month
>
0
?
this
.
Month
:
today
.
Month
;
ary
[
4
]
=
this
.
Year
>
0
?
this
.
Year
:
today
.
Year
;
p
[
2
]
=
this
.
Day
>
0
?
this
.
Day
:
today
.
Day
;
p
[
3
]
=
this
.
Month
>
0
?
this
.
Month
:
today
.
Month
;
p
[
4
]
=
this
.
Year
>
0
?
this
.
Year
:
today
.
Year
;
return
ary
;
return
new
DateTime
(
p
[
4
],
p
[
3
],
p
[
2
],
p
[
1
],
p
[
0
],
0
)
;
}
/// <summary>
///
Converts the date time components into a datetime object
.
///
Gets an array of all date parts to construct a datetime instance
.
/// </summary>
/// <returns>
A datetime object
</returns>
internal
DateTime
ToDateTime
()
/// <returns>
[min, hour, day, month, year]
</returns>
private
int
[]
ToArray
()
{
var
p
=
this
.
ToArray2
();
return
new
DateTime
(
p
[
4
],
p
[
3
],
p
[
2
],
p
[
1
],
p
[
0
],
0
);
return
new
int
[]
{
this
.
Minute
,
this
.
Hour
,
this
.
Day
,
this
.
Month
,
this
.
Year
};
}
}
}
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Trigger.cs
View file @
dbb83bbe
...
...
@@ -214,7 +214,6 @@ namespace LocalNotificationProxy.LocalNotification
private
DateTime
GetRelDate
()
{
var
every
=
this
.
Every
as
Every
;
var
p
=
every
.
ToArray2
();
var
date
=
every
.
ToDateTime
();
var
now
=
DateTime
.
Now
;
...
...
@@ -232,13 +231,12 @@ namespace LocalNotificationProxy.LocalNotification
case
"day"
:
if
(
every
.
YearIsVariable
)
{
p
[
4
]
=
now
.
Year
+
1
;
return
date
.
AddYears
(
now
.
Year
-
date
.
Year
+
1
)
;
}
break
;
case
"year"
:
p
[
4
]
=
now
.
Year
+
1
;
break
;
return
date
.
AddYears
(
now
.
Year
-
date
.
Year
+
1
);
}
}
else
if
(
date
.
Day
<
now
.
Day
)
...
...
@@ -249,22 +247,18 @@ namespace LocalNotificationProxy.LocalNotification
case
"hour"
:
if
(
every
.
MonthIsVariable
)
{
// TODO: end of year
p
[
3
]
=
now
.
Month
+
1
;
return
date
.
AddMonths
(
now
.
Month
-
date
.
Month
+
1
);
}
else
if
(
every
.
YearIsVariable
)
{
p
[
4
]
=
now
.
Year
+
1
;
return
date
.
AddYears
(
now
.
Year
-
date
.
Year
+
1
)
;
}
break
;
case
"month"
:
// TODO: end of year
p
[
3
]
=
now
.
Month
+
1
;
break
;
return
date
.
AddMonths
(
now
.
Month
-
date
.
Month
+
1
);
case
"year"
:
p
[
4
]
=
now
.
Year
+
1
;
break
;
return
date
.
AddYears
(
now
.
Year
-
date
.
Year
+
1
);
}
}
else
if
(
date
.
Hour
<
now
.
Hour
)
...
...
@@ -274,31 +268,22 @@ namespace LocalNotificationProxy.LocalNotification
case
"minute"
:
if
(
every
.
DayIsVariable
)
{
// TODO: end of month
p
[
2
]
=
now
.
Day
+
1
;
return
date
.
AddDays
(
now
.
Day
-
date
.
Day
+
1
);
}
else
if
(
every
.
MonthIsVariable
)
{
// TODO: end of year
p
[
3
]
=
now
.
Month
+
1
;
return
date
.
AddMonths
(
now
.
Month
-
date
.
Month
+
1
);
}
break
;
case
"hour"
:
// TODO: end of day
p
[
1
]
=
now
.
Hour
;
break
;
return
date
.
AddHours
(
now
.
Hour
-
date
.
Hour
);
case
"day"
:
// TODO: end of month
p
[
2
]
=
now
.
Day
+
1
;
break
;
return
date
.
AddDays
(
now
.
Day
-
date
.
Day
+
1
);
case
"month"
:
// TODO: end of year
p
[
3
]
=
now
.
Month
+
1
;
break
;
return
date
.
AddMonths
(
now
.
Month
-
date
.
Month
+
1
);
case
"year"
:
p
[
4
]
=
now
.
Year
+
1
;
break
;
return
date
.
AddYears
(
now
.
Year
-
date
.
Year
+
1
);
}
}
else
if
(
date
.
Minute
<
now
.
Minute
)
...
...
@@ -306,29 +291,18 @@ namespace LocalNotificationProxy.LocalNotification
switch
(
every
.
Interval
)
{
case
"minute"
:
// TODO: end of hour
p
[
0
]
=
now
.
Minute
+
1
;
break
;
return
date
.
AddMinutes
(
now
.
Minute
-
date
.
Minute
+
1
);
case
"hour"
:
// TODO: end of day
p
[
1
]
=
now
.
Hour
+
1
;
break
;
return
date
.
AddHours
(
now
.
Hour
-
date
.
Hour
+
1
);
case
"day"
:
// TODO: end of month
p
[
2
]
=
now
.
Day
+
1
;
break
;
return
date
.
AddDays
(
now
.
Day
-
date
.
Day
+
1
);
case
"month"
:
// TODO: end of year
p
[
3
]
=
now
.
Month
+
1
;
break
;
return
date
.
AddMonths
(
now
.
Month
-
date
.
Month
+
1
);
case
"year"
:
p
[
4
]
=
now
.
Year
+
1
;
break
;
return
date
.
AddYears
(
now
.
Year
-
date
.
Year
+
1
);
}
}
date
=
new
DateTime
(
p
[
4
],
p
[
3
],
p
[
2
],
p
[
1
],
p
[
0
],
0
);
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