Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use nice_date changes from lingua franca #59

Merged
merged 3 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from ovos_skills_manager.utils import get_skills_examples
from ovos_utils.process_utils import RuntimeRequirements
from ovos_utils import classproperty
from lingua_franca.format import get_date_strings


class OVOSHomescreenSkill(MycroftSkill):
Expand Down Expand Up @@ -87,7 +88,7 @@ def initialize(self):
self.rtlMode = 1 if self.config_core.get("rtl", False) else 0

self.datetime_skill = self.settings.get(
"datetime_skill") or "skill-ovos-date-time.openvoiceos"
"datetime_skill")
self.examples_enabled = 1 if self.settings.get(
"examples_enabled", True) else 0

Expand Down Expand Up @@ -220,18 +221,28 @@ def update_dt(self):
"""
Loads or updates date/time via the datetime_api.
"""
if not self.datetime_api:
LOG.warning("Requested update before datetime API loaded")
self._load_skill_apis()
if self.datetime_api:
self.gui["time_string"] = self.datetime_api.get_display_current_time()
self.gui["date_string"] = self.datetime_api.get_display_date()
self.gui["weekday_string"] = self.datetime_api.get_weekday()
self.gui['day_string'], self.gui["month_string"] = self._split_month_string(
self.datetime_api.get_month_date())
self.gui["year_string"] = self.datetime_api.get_year()
if self.datetime_skill:
if not self.datetime_api:
LOG.warning("Requested update before datetime API loaded")
self._load_skill_apis()
if self.datetime_api:
self.gui["time_string"] = self.datetime_api.get_display_current_time()
self.gui["date_string"] = self.datetime_api.get_display_date()
self.gui["weekday_string"] = self.datetime_api.get_weekday()
self.gui['day_string'], self.gui["month_string"] = self._split_month_string(
self.datetime_api.get_month_date())
self.gui["year_string"] = self.datetime_api.get_year()
else:
LOG.warning("No datetime_api, skipping update")
else:
LOG.warning("No datetime_api, skipping update")
date_string_object = get_date_strings(date_format=self.config_core.get("date_format", "MDY"),
lang=self.lang)
self.gui["time_string"] = date_string_object.get("time_string")
self.gui["date_string"] = date_string_object.get("date_string")
self.gui["weekday_string"] = date_string_object.get("weekday_string")
self.gui["day_string"] = date_string_object.get("day_string")
self.gui["month_string"] = date_string_object.get("month_string")
self.gui["year_string"] = date_string_object.get("year_string")

def update_weather(self):
"""
Expand Down Expand Up @@ -366,8 +377,9 @@ def _load_skill_apis(self):
"""
# Import Date Time Skill As Date Time Provider
try:
if not self.datetime_api:
self.datetime_api = SkillApi.get(self.datetime_skill)
if self.datetime_skill:
if not self.datetime_api:
self.datetime_api = SkillApi.get(self.datetime_skill)
except Exception as e:
LOG.error(f"Failed to import DateTime Skill: {e}")

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ requests>=2.26.0
ovos-utils~=0.0, >=0.0.28a4
ovos_workshop~=0.0, >=0.0.11a4
ovos-skills-manager>=0.0.12a1
ovos-lingua-franca>=0.4.7a1