This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function localTimeToUtc(localHours, localMinutes) { | |
const date = new Date() | |
const now = new Date(date.getFullYear(), date.getMonth(), date.getDate(), localHours, localMinutes) // UTC | |
const utcHours = now.getUTCHours() | |
const utcMinutes = now.getUTCMinutes() | |
return {utcHours, utcMinutes} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// parameter hmTime is a string containing 5 characters, | |
// first two is hours, last to is minutes, which are divied with ':', | |
// e.g., "08:15", "17:43" | |
const _ = require('lodash'); | |
function localHhMmToUtc(hmTime) { | |
const splitted = _.split(hmTime, ':') | |
const localHours = splitted[0]; | |
const localMinutes = splitted[1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// API Request: | |
// http://newsky2.kma.go.kr/service/SecndSrtpdFrcstInfoService2/ForecastTimeData?ServiceKey=SERVICE_KEY | |
// &base_date=20181001 | |
// &base_time=1230 | |
// &nx=55&ny=127 | |
// &pageNo=1&numOfRows=60 | |
// &_type=json | |
// JSON Response: | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// API Request: | |
// http://newsky2.kma.go.kr/service/SecndSrtpdFrcstInfoService2/ForecastGrib?ServiceKey=SERVICE_KEY | |
// &base_date=20181001 | |
// &base_time=1200 | |
// &nx=60&ny=127 | |
// &pageNo=1&numOfRows=20 | |
// &_type=json | |
// JSON Response: | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// API Request: | |
// http://newsky2.kma.go.kr/service/SecndSrtpdFrcstInfoService2/ForecastSpaceData?ServiceKey=SERVICE_KEY | |
// &base_date=20181001 | |
// &base_time=1100 | |
// &nx=55&ny=127 // NOTE: This is not latitude and longitude. It is KMA defined grid number. | |
// &_type=json | |
// &numOfRows=1000 | |
// Response JSON: | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function myActionCreator() { | |
return async dispatch => { | |
const CancelToken = axios.CancelToken | |
const source = CancelToken.source() | |
try { | |
let req = null; | |
setTimeout(() => { | |
if (req == null) { | |
console.log(`Request Timeout with req == null.`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function myActionCreator() { | |
return async dispatch => { | |
try { | |
req = await axios.get(url, {timeout: 4000}); | |
dispatch ({ | |
type: ACTION_TYPE, | |
payload: req.data, | |
}) | |
} catch (e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the first code | |
Animated.parallel([ // 윈도우를 슬라이드인, 페이드인 한다. | |
Animated.timing( | |
this.state.fadeAnim, | |
{ | |
toValue: 1, | |
duration: isAndroid ? androidDuration : iosDuration, | |
easing: Easing.in(), | |
useNativeDriver, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Better way to show and hide window | |
*/ | |
Animated.sequence([ | |
Animated.parallel([ // 윈도우를 슬라이드인, 페이드인 한다. | |
Animated.timing( | |
this.state.fadeAnim, | |
{ | |
toValue: 1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Not so good way to slide in, show for 4 seconds, and then hide window | |
*/ | |
Animated.parallel([ // 윈도우를 슬라이드인, 페이드인 한다. | |
Animated.timing( | |
this.state.fadeAnim, | |
{ | |
toValue: 1, | |
duration: isAndroid ? androidDuration : iosDuration, | |
easing: Easing.in(), |