package Ġcom . example . j uli oc at ano . weather app kotlin . data . map pers Ċ Ċ import Ġcom . example . j uli oc at ano . weather app kotlin . data . model . Forecast Ċ import Ġcom . example . j uli oc at ano . weather app kotlin . data . model . Forecast Result Ċ import Ġcom . example . j uli oc at ano . weather app kotlin . domain . entities . Forecast List Ċ import Ġjava . text . DateFormat Ċ import Ġjava . util .* Ċ import Ġjava . util . concurrent . TimeUnit Ċ import Ġcom . example . j uli oc at ano . weather app kotlin . domain . entities . Forecast Ġas ĠModel Forecast Ċ Ċ class ĠFore cast Data Mapper Ġ{ ĊĊĠĠĠ Ġfun Ġconvert From DataModel ( forecast : ĠFore cast Result ) Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠFore cast List ( forecast . city . name , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġforecast . city . country , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġconvert Forecast List To Domain ( forecast . list )) ĊĊĠĠĠ Ġprivate Ġfun Ġconvert Forecast List To Domain ( list : ĠList < Forecast >): ĠList < Model Forecast > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġlist . map Indexed Ġ{ Ġi , Ġforecast Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġdt Ġ= ĠCalendar . getInstance (). time In Millis Ġ+ ĠTimeUnit . DAYS . to Millis ( i . to Long ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconvert Forecast Item To Domain ( forecast . copy ( dt Ġ= Ġdt )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġconvert Forecast Item To Domain ( forecast : ĠFore cast ): ĠModel Forecast Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠModel Forecast ( convert Date ( forecast . dt ), Ġforecast . weather [ 0 ]. description , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġforecast . temp . max . toInt (), Ġforecast . temp . min . toInt (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġgenerate Icon Url ( forecast . weather [ 0 ]. icon )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġgenerate Icon Url ( icon Code : ĠString ) Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" http :// open weather map . org / img / w /$ icon Code . png " ĊĊĠĠĠ Ġprivate Ġfun Ġconvert Date ( date : ĠLong ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdf Ġ= ĠDate Format . getDate Instance ( DateFormat . MEDIUM , ĠLocale . getDefault ()) ĊĠĠĠĠĠĠĠ Ġreturn Ġdf . format ( date ) ĊĠĠĠ Ġ} Ċ Ċ } Ċ