omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Person birthday property, error when no year

    Pythonista
    3
    3
    1948
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jrwagz
      jrwagz last edited by

      I have a few contacts in my Contacts app that have birthdays with no year associated. This allows them to show up in the calendar even though I don't know the year.

      When I try and access the birthday property on these contacts, I get the following error:

      >> person.birthday
      Traceback (most recent call last):
      File "<string>", line 1, in <module>
      ValueError: timestamp out of range for platform time_t
      

      Is there any way to handle this correctly?

      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        Thanks, I wasn't aware of this problem. I don't think there's a workaround, but I'll put this on my todo list.

        1 Reply Last reply Reply Quote 0
        • ccc
          ccc last edited by

          Try / Except is your friend...

          for person in contacts.get_all_people():
              try:
                  birthday = person.birthday
              except ValueError:
                  birthday = None
                  print(person.full_name + ' has an invalid birthday.')
              if birthday:
                  ...
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors