πŸ’Ύ Archived View for gmi.bacardi55.io β€Ί blog β€Ί 2017 β€Ί 03 β€Ί 19 β€Ί kalliope-what-time-is-it-in captured on 2024-08-18 at 17:38:58. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

KalliopΓ©, what time is it in …

Posted on 2017-03-19

Introduction

When you work with multiple country and different timezone, you're always wondering what time it is there… And I was fed up to keep opening a tab in a browser to find out again and again.

So I decided to create a kalliopΓ© neuron to be able to ask kalliopΓ©[1] what time it is in any city / country :) and I create the [wwtime neuron]https://github.com/bacardi55/kalliope-wwtime([2]) to do so!

1: https://kalliope-project.github.io/

2: https://github.com/bacardi55/kalliope-wwtime(

How

Getting timezone for address

This neuron will retrieve a local timezone and a requested city timezone. It compares timezone difference (including summer time) between the two location to give you the time there based on your timezone.

Eg:

When it's 10pm in Paris, Kalliope will tell me it is 5pm in Boston (because as of now, boston is in summer time and paris not yet, so -5 and not -6)

It uses GoogleMaps API to get geolocation data based on a city name or address. So you need to activate to Google API:

To make it works, you will need to get an API key on your developer console[5]. Or follow documentation here[6] and here[7]

3: https://developers.google.com/maps/documentation/timezone/intro

4: https://developers.google.com/maps/documentation/geocoding/intro

5: https://console.developers.google.com/apis/dashboard

6: https://developers.google.com/maps/documentation/geocoding/get-api-key

7: https://developers.google.com/maps/documentation/timezone/get-api-key

Installation

  kalliope install --git-url https://github.com/bacardi55/kalliope-wwtimes.git

Options

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   parameter   β”‚ required β”‚ default β”‚ choices β”‚            comment            β”‚
β•žβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•ͺ══════════β•ͺ═════════β•ͺ═════════β•ͺ═══════════════════════════════║
β”‚ gmaps_api_key β”‚ yes      β”‚         β”‚ string  β”‚ The api key to use googlemaps β”‚
β”‚               β”‚          β”‚         β”‚         β”‚ API. See above.               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ local         β”‚ yes      β”‚         β”‚ string  β”‚ Your city/address to compare  β”‚
β”‚               β”‚          β”‚         β”‚         β”‚ time difference with          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ city          β”‚ yes      β”‚         β”‚ string  β”‚ What city/address where you   β”‚
β”‚               β”‚          β”‚         β”‚         β”‚ want to know time             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Return Values

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Name  β”‚     Description     β”‚  Type  β”‚                sample                β”‚
β•žβ•β•β•β•β•β•β•β•β•ͺ═════════════════════β•ͺ════════β•ͺ══════════════════════════════════════║
β”‚ status β”‚ Response status     β”‚ String β”‚ OK or KO                             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚        β”‚                     β”‚        β”‚ [arg: 'new york city', 'timezoneid': β”‚
β”‚ city   β”‚ A dictΒΉ (see below) β”‚ dict   β”‚ 'America/New_York', 'timezonename':  β”‚
β”‚        β”‚                     β”‚        β”‚ 'Eastern Daylight Time', time:       β”‚
β”‚        β”‚                     β”‚        β”‚ {'hour': '10', 'minute': '30'}]      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚        β”‚                     β”‚        β”‚ [arg: 'Paris France', 'timezoneid':  β”‚
β”‚        β”‚                     β”‚        β”‚ 'Europe/Paris', 'timezonename':      β”‚
β”‚ local  β”‚ A dictΒΉ (see below) β”‚ dict   β”‚ 'Central European Standard Time',    β”‚
β”‚        β”‚                     β”‚        β”‚ time: {'hour': '10', 'minute':       β”‚
β”‚        β”‚                     β”‚        β”‚ '30'}]                               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

ΒΉ: these dict contains:

Synapses example

brains

Get a city by argument in order

  - name: "Wwtime-city"
    signals:
      - order: "what time is it in {{city}}"
    neurons:
      - wwtime:
          gmaps_api_key: "{{gmaps_api_key}}"
          local: "Paris France"
          args:
            - city
          file_template: "templates/fr_wwtime.j2"

Get a city by argument set in brain:

  - name: "Wwtime-city-boton"
    signals:
      - order: "heure boston"
    neurons:
      - wwtime:
          gmaps_api_key: "{{gmaps_api_key}}"
          city: "boston MA"
          local: "Paris France"
          file_template: "templates/fr_wwtime.j2"

template

  {% raw %}
  {% if status == "OK" %}
      Sir, in {{city.arg}}, it is {{city.time.hour}} hour and {{city.time.minute}} minutes, whereas here, it's {{local.time.hour}} hour and {{local.time.minute}} minutes
      Le timezone est {{city.timezonename}}
  {% else %}
      Sorry sir, but I don't know
  {% endif %}
  {% endraw %}

see more example in the sample directory

/gemlog/

Send me a gemini mention

send me an email!