// Compiled by ClojureScript 1.10.520 {}
goog.provide('weathergen.time');
goog.require('cljs.core');
/**
 * Converts a campaign time map to a long - a time in milliseconds.
 */
weathergen.time.campaign_time__GT_ms = (function weathergen$time$campaign_time__GT_ms(p__24495){
var map__24496 = p__24495;
var map__24496__$1 = (((((!((map__24496 == null))))?(((((map__24496.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__24496.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__24496):map__24496);
var t = map__24496__$1;
var day = cljs.core.get.call(null,map__24496__$1,new cljs.core.Keyword(null,"day","day",-274800446));
var hour = cljs.core.get.call(null,map__24496__$1,new cljs.core.Keyword(null,"hour","hour",-555989214));
var minute = cljs.core.get.call(null,map__24496__$1,new cljs.core.Keyword(null,"minute","minute",-642875969));
var second = cljs.core.get.call(null,map__24496__$1,new cljs.core.Keyword(null,"second","second",-444702010));
var millisecond = cljs.core.get.call(null,map__24496__$1,new cljs.core.Keyword(null,"millisecond","millisecond",-540123566));
return ((((((((day * (24)) + hour) * (60)) + minute) * (60)) + second) * (1000)) + millisecond);
});
/**
 * Converts a time in milliseconds to a campaign time map.
 */
weathergen.time.ms__GT_campaign_time = (function weathergen$time$ms__GT_campaign_time(data){
var d = cljs.core.long$.call(null,((((data / (24)) / (60)) / (60)) / (1000)));
var h = cljs.core.long$.call(null,(((cljs.core.mod.call(null,data,((((24) * (60)) * (60)) * (1000))) / (60)) / (60)) / (1000)));
var m = cljs.core.long$.call(null,((cljs.core.mod.call(null,data,(((60) * (60)) * (1000))) / (60)) / (1000)));
var s = cljs.core.long$.call(null,(cljs.core.mod.call(null,data,((60) * (1000))) / (1000)));
var ms = cljs.core.mod.call(null,data,(1000));
return new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"day","day",-274800446),(d + (1)),new cljs.core.Keyword(null,"hour","hour",-555989214),h,new cljs.core.Keyword(null,"minute","minute",-642875969),m,new cljs.core.Keyword(null,"second","second",-444702010),s,new cljs.core.Keyword(null,"millisecond","millisecond",-540123566),ms], null);
});
/**
 * Converts a time in minutes to a campaign time map.
 */
weathergen.time.minutes__GT_campaign_time = (function weathergen$time$minutes__GT_campaign_time(min){
var d = (Math.floor(((min / (24)) / (60))) | (0));
var h = (Math.floor((cljs.core.mod.call(null,min,((24) * (60))) / (60))) | (0));
var m = (Math.floor(cljs.core.mod.call(null,min,(60))) | (0));
return new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"day","day",-274800446),(d + (1)),new cljs.core.Keyword(null,"hour","hour",-555989214),h,new cljs.core.Keyword(null,"minute","minute",-642875969),m], null);
});
/**
 * Converts from Falcon time to a weather-space time coordinate.
 */
weathergen.time.campaign_time__GT_minutes = (function weathergen$time$campaign_time__GT_minutes(t){
var map__24498 = t;
var map__24498__$1 = (((((!((map__24498 == null))))?(((((map__24498.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__24498.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__24498):map__24498);
var day = cljs.core.get.call(null,map__24498__$1,new cljs.core.Keyword(null,"day","day",-274800446));
var hour = cljs.core.get.call(null,map__24498__$1,new cljs.core.Keyword(null,"hour","hour",-555989214));
var minute = cljs.core.get.call(null,map__24498__$1,new cljs.core.Keyword(null,"minute","minute",-642875969));
return (((((day - (1)) * (24)) + hour) * (60)) + minute);
});
/**
 * Adds minutes to a Falcon time map.
 */
weathergen.time.add_minutes = (function weathergen$time$add_minutes(t,min){
return weathergen.time.minutes__GT_campaign_time.call(null,(weathergen.time.campaign_time__GT_minutes.call(null,t) + min));
});
/**
 * Returns a difference in hours, minutes, and seconds (in a map) between two campaign times
 */
weathergen.time.difference_hms = (function weathergen$time$difference_hms(t1,t2){
var map__24500 = weathergen.time.ms__GT_campaign_time.call(null,(weathergen.time.campaign_time__GT_ms.call(null,t2) - weathergen.time.campaign_time__GT_ms.call(null,t1)));
var map__24500__$1 = (((((!((map__24500 == null))))?(((((map__24500.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__24500.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__24500):map__24500);
var t = map__24500__$1;
var day = cljs.core.get.call(null,map__24500__$1,new cljs.core.Keyword(null,"day","day",-274800446));
var hour = cljs.core.get.call(null,map__24500__$1,new cljs.core.Keyword(null,"hour","hour",-555989214));
return cljs.core.update.call(null,cljs.core.dissoc.call(null,t,new cljs.core.Keyword(null,"day","day",-274800446)),new cljs.core.Keyword(null,"hour","hour",-555989214),cljs.core._PLUS_,((24) * (day - (1))));
});
