Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
weather
Commits
a50296e1
Commit
a50296e1
authored
May 25, 2017
by
Zac Wood
Browse files
Added time zone awareness to each location (closes
#30
)
parent
08a24b6e
Changes
2
Hide whitespace changes
Inline
Side-by-side
weather/client/views/weather/weather.js
View file @
a50296e1
import
moment
from
'
moment-timezone
'
;
Template
.
weather
.
helpers
({
weatherData
:
function
()
{
weatherDataDependency
.
depend
();
...
...
@@ -50,16 +52,20 @@ Template.weather.helpers({
//Formats a unix timestamp a full human readable time
formatTimestamp
:
function
(
timestamp
)
{
if
(
timestamp
===
undefined
)
return
"
...
"
;
var
d
=
new
Date
(
timestamp
*
1000
);
//console.log("GOT: "+timestamp)
return
d
.
toLocaleString
(
"
en-us
"
,
{
hour
:
'
numeric
'
,
minute
:
'
numeric
'
,
timeZoneName
:
'
short
'
});
// See https://momentjs.com/timezone/
var
d
=
moment
.
tz
(
timestamp
*
1000
,
weatherData
.
data
.
timezone
).
format
(
'
YYYY-MM-DD HH:MM z
'
);
return
d
.
format
();
},
//Formats unix time to just a 12 hour time
formatTimestampToHour
:
function
(
timestamp
)
{
if
(
timestamp
===
undefined
)
return
"
...
"
;
var
d
=
new
Date
(
timestamp
*
1000
);
//console.log("GOT: "+timestamp)
return
d
.
toLocaleString
(
"
en-us
"
,
{
hour
:
'
numeric
'
});
// See https://momentjs.com/timezone/
var
time
=
moment
.
tz
(
timestamp
*
1000
,
weatherData
.
data
.
timezone
).
format
(
'
h A (z)
'
);
return
time
;
},
//Converts icon names from darksky to those that can be used by our css library
convertIconName
:
function
(
apiIcon
)
{
...
...
weather/package.json
View file @
a50296e1
...
...
@@ -9,6 +9,7 @@
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"babel-runtime"
:
"^6.22.0"
"babel-runtime"
:
"^6.22.0"
,
"moment-timezone"
:
"^0.5.13"
}
}
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