<commit_before>import Ember from 'ember';

export default Ember.Service.extend({
  init(){
    console.log('im trasport service');
  },

  requestDataFromTrasportApi(data){
    const apiKey = '210cd3d0b88f32603edc631a13ce14f9';
    const apiId = '81d2c3ad';
    let fromLng = data.from.geometry.location.lng();
    let fromLat = data.from.geometry.location.lat();
    let toLng = data.to.geometry.location.lng();
    let toLat = data.to.geometry.location.lat();
    let date = '2016-08-09';
    let time = '20:50';

    //let link = 'http://transportapi.com/v3/uk/public/journey/from/stop:London+bridge/to/stop:Canary+wharf/at/2016-10-18/15:29.json?api_key='+ apiKey +'&app_id='+ apiId + '&modes=bus-train-tube';
    // let link = 'http://transportapi.com/v3/uk/public/journey/from/lonlat:'+ fromLng +','+ fromLat +'/to/lonlat:'+ toLng +','+ toLat +'.json?api_key='+ apiKey +'&app_id='+ apiId + '&modes=bus-train-tube';

    let link = `http://transportapi.com/v3/uk/public/journey/from/lonlat:${fromLng},${fromLat}/to/lonlat:${toLng},${toLat}/by/${date}/${time}.json?api_key=${apiKey}&app_id=${apiId}&modes=bus-train-tube&region=southeast`;
    console.log(link);

    return fetch(link)
      .then((response)=>{
        return response.json()
          .then((jsonResponse)=>{
            console.log(jsonResponse);
            return jsonResponse;
          });
      }).catch((err)=>{
        console.log('Failded to fetch data from trasportApi: ' + err);
      });
  },

});<commit_msg>feat: Format date and time for trasport api<commit_after>import Ember from 'ember';

export default Ember.Service.extend({
  init(){
    console.log('im trasport service');
  },

  requestDataFromTrasportApi(data){
    const apiKey = '210cd3d0b88f32603edc631a13ce14f9';
    const apiId = '81d2c3ad';
    let fromLng = data.from.geometry.location.lng();
    let fromLat = data.from.geometry.location.lat();
    let toLng = data.to.geometry.location.lng();
    let toLat = data.to.geometry.location.lat();
    let date = '2016-08-09';
    let time = '20:50';

    //let link = 'http://transportapi.com/v3/uk/public/journey/from/stop:London+bridge/to/stop:Canary+wharf/at/2016-10-18/15:29.json?api_key='+ apiKey +'&app_id='+ apiId + '&modes=bus-train-tube';
    // let link = 'http://transportapi.com/v3/uk/public/journey/from/lonlat:'+ fromLng +','+ fromLat +'/to/lonlat:'+ toLng +','+ toLat +'.json?api_key='+ apiKey +'&app_id='+ apiId + '&modes=bus-train-tube';

    let link = `http://transportapi.com/v3/uk/public/journey/from/lonlat:${fromLng},${fromLat}/to/lonlat:${toLng},${toLat}/by/${date}/${time}.json?api_key=${apiKey}&app_id=${apiId}&modes=bus-train-tube&region=southeast`;
    console.log(link);

    return fetch(link)
      .then((response)=>{
        return response.json()
          .then((jsonResponse)=>{
            console.log(jsonResponse);
            return jsonResponse;
          });
      }).catch((err)=>{
        console.log('Failded to fetch data from trasportApi: ' + err);
      });
  },

  formatDate(date){
    if(date){
      let year = date.getFullYear();
      let day =  date.getDate() < 10 ? `0${date.getDate()}` : date.getDate();
      let month = date.getMonth() + 1 < 10 ? `0${(date.getMonth() + 1)}` : date.getMonth() + 1;
      return `${year}-${month}-${day}`;
    } else {
      return null;
    }

  },

  formatTime(time){
    if(time){
      if(time % 60 === 0){
        return `${time / 60}:00`;
      } else {
        return `${(time - 30) / 60 }:30`;
      }
    } else {
      return null;
    }

  },

});
{'fraction_non_alphanumeric': 0.19554804170188786, 'fraction_numerical': 0.03493941955480417, 'mean_word_length': 3.152046783625731, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2617212', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1289, 'n_words': 203}