kivymd / KivyMD

KivyMD is a collection of Material Design compliant widgets for use with Kivy, a framework for cross-platform, touch-enabled graphical applications. https://youtube.com/c/KivyMD https://twitter.com/KivyMD https://habr.com/ru/users/kivymd https://stackoverflow.com/tags/kivymd
https://kivymd.readthedocs.io
MIT License
2.26k stars 674 forks source link

Fix time.strftime("%p") #1729

Open kengoon opened 3 months ago

kengoon commented 3 months ago

The below code does not work properly on other platforms except android https://github.com/kivymd/KivyMD/blob/b5bc79fb71312868be86580b7b32f676926ceb80/kivymd/uix/pickers/timepicker/timepicker.py#L825-L839

The reason is simply because materialyoucolor-python which KivyMD depends on has an exception with pyjnius that was not handled properly, thereby messing up with time.strftime("%p"). A fix for that is already on the way. So when fix is merged, the _get_data method should be updated to something like this

def _get_data(self):
        result = datetime.datetime.strptime(
            f"{int(self.hour):02d}:{int(self.minute):02d} {self.am_pm}",
            "%I:%M %p",
        ).time()
        return result