FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
angular-date-range/angular-date-range.js at master · DevLab2425/angular-date-range · GitHub
DevLab2425
/
angular-date-range
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
3
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
angular-date-range
/
angular-date-range.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
46 lines (39 loc) · 1.39 KB
Breadcrumbs
angular-date-range
/
angular-date-range.js
Copy path
File metadata and controls
46 lines (39 loc) · 1.39 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
var
DateRange
=
angular
.
module
(
'date-range'
,
[
]
)
;
DateRange
.
directive
(
'dateRange'
,
[
'$filter'
,
function
(
$filter
)
{
return
{
scope
:
{
startDate
:
'@'
,
endDate
:
'@'
}
,
template
:
'<span class="range">{{range}}</span>'
,
restrict
:
'AE'
,
replace
:
false
,
link
:
function
(
$scope
,
iElm
,
iAttrs
,
controller
)
{
// DEFAULT VALUES IF ATTRIBUTES DON'T EXIST
if
(
!
iAttrs
.
startDate
)
{
iAttrs
.
startDate
=
'January 1, 1970'
;
}
if
(
!
iAttrs
.
endDate
)
{
iAttrs
.
endDate
=
'January 31, 1970'
;
}
var
output
=
''
;
var
monthsOfYear
=
[
'January'
,
'February'
,
'March'
,
'April'
,
'May'
,
'June'
,
'July'
,
'August'
,
'September'
,
'October'
,
'November'
,
'December'
]
;
var
fromDate
=
new
Date
(
iAttrs
.
startDate
)
;
var
endDate
=
new
Date
(
iAttrs
.
endDate
)
;
var
from
=
{
month
:
monthsOfYear
[
fromDate
.
getMonth
(
)
]
,
day
:
fromDate
.
getDate
(
)
,
year
:
fromDate
.
getFullYear
(
)
}
;
var
end
=
{
month
:
monthsOfYear
[
endDate
.
getMonth
(
)
]
,
day
:
endDate
.
getDate
(
)
,
year
:
endDate
.
getFullYear
(
)
}
;
if
(
from
.
month
===
end
.
month
)
{
// MMMM d - d, yyyy
output
=
$filter
(
'date'
)
(
fromDate
,
'MMMM d'
)
+
' - '
+
$filter
(
'date'
)
(
endDate
,
'd, yyyy'
)
;
}
else
{
// MMMM d - MMMM d, yyyy
output
=
$filter
(
'date'
)
(
fromDate
,
'MMMM d, yyyy'
)
+
' - '
+
$filter
(
'date'
)
(
endDate
,
'MMMM d, yyyy'
)
;
}
$scope
.
range
=
output
;
}
}
;
}
]
)
;
Back
|
FazBrowse Home
|
New Git URL