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

Updated plugin.py #677

Merged
merged 1 commit into from
Aug 6, 2024
Merged

Updated plugin.py #677

merged 1 commit into from
Aug 6, 2024

Conversation

Orlandoxx
Copy link
Contributor

Fixed date & time

Fixed date & time
Copy link

sonarcloud bot commented Aug 6, 2024

@Huevos
Copy link
Member

Huevos commented Aug 6, 2024

Did you try, c = time.strptime(item.observationtime, "%EX"), which should use the locale's representation for HMS.

@Orlandoxx
Copy link
Contributor Author

No, because what to use for HM then ? That try/except combo works, so be it. You can always change the solution, If you have a better one.

try:
c = time.strptime(item.observationtime, "%H:%M:%S")
self["observationtime"].text = _("Observation time: %s") % time.strftime("%H:%M", c)
except:
c = time.strptime(item.observationtime, "%H.%M.%S")
self["observationtime"].text = _("Observation time: %s") % time.strftime("%H.%M", c)

@Huevos
Copy link
Member

Huevos commented Aug 6, 2024

c = time.strptime(item.observationtime, "%EX")
self["observationtime"].text = _("Observation time: %s") % time.strftime("%EX", c)[:5]

@Orlandoxx
Copy link
Contributor Author

With your patch, I get : 'E' is a bad directive in format '%EX'
So can you merge my patch ?

@Huevos
Copy link
Member

Huevos commented Aug 6, 2024

I think Birdman has added this confusion. That format is for linux function strptime.

@Huevos Huevos merged commit 1cec2b2 into oe-alliance:master Aug 6, 2024
7 checks passed
@Orlandoxx
Copy link
Contributor Author

OK, but I tested this:

c = time.strptime(item.observationtime, "%X")
self["observationtime"].text = _("Observation time: %s") % time.strftime("%X", c)[:5]

and this works. Would you like to change this or leave it ?

@Orlandoxx Orlandoxx deleted the patch-1 branch August 6, 2024 16:10
@Huevos
Copy link
Member

Huevos commented Aug 6, 2024

Yes please update. Avoid try except.

@Orlandoxx
Copy link
Contributor Author

Allright. I will make a new patch and a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants