UNPKG

sun-time

Version:

Calculator of sunrise time as well as sunset time according to location(Long.,lat.) or city name.

48 lines (34 loc) 1.16 kB
((ETL,JFile,JsDK,api)=>{ class City{ // {name,namesi18n,long,lat,country} constructor(o){ for(var p in o){ this[p]=o[p]; } } get location(){ return {long:this.long,lat:this.lat}; } }; api.process_moodoon=(line,opts)=>{ let result={},tmp='',i18n; tmp=line.split(ETL.DLM_SPACE_OR_MORE); result.lat=tmp[tmp.length-10];result.long=tmp[tmp.length-9]; if(result.long==='P'){ result.lat=tmp[tmp.length-11];result.long=tmp[tmp.length-10]; } result.lat=parseFloat(result.lat);result.long=parseFloat(result.long); result.tzone=tmp[tmp.length-2]; if((tmp[1] !== tmp[2]) && (parseFloat(tmp[7])===result.lat)){ // lat:7 result.name=`${tmp[1]} ${tmp[2]}`; result.namei18n=`${tmp[5]} ${tmp[6]}`; }else{ //lat:4 result.name=tmp[1]; result.namei18n=tmp[3]; } return result; }; module.exports=api; })(require('node-etl'),require('jfile'),require('x-class'),{});