SufficientlySecure / birthday-calendar

Display all contact birthdays automatically in your standard Android calendar.
https://www.schuermann.eu/android/
GNU General Public License v3.0
95 stars 28 forks source link

Dates are parsed incorrectly (Motorola Defy) #34

Closed dschuermann closed 11 years ago

dschuermann commented 11 years ago

Original author: d.lai...@gmail.com (January 07, 2013 20:22:37)

On my phone I'm using birthday-adapter on my Owncloud address book synced with CalDav-Sync. However, the dates of the generated events do not match the birthdays at all.

This is probably due to my phone using timestamps as a date format (see [1]).

For example the date 1989-12-24 becomes September 4 in the calendar. With another contact editor [2] the birthday field contains 627943569622. Divide this by 1000 and you get a Unix timestamp that matches the birthday (and the time seems to match the time I entered it -- for whatever reason).

I would suggest to either auto-detect the date format or make it configurable.

[1] http://dmfs.org/carddav/?date_format [2] https://play.google.com/store/apps/details?id=org.dmfs.android.contacts

(Using version 1.3/org.birthdayadapter_4.apk from F-Droid on Android 2.2.2.)

Original issue: http://code.google.com/p/birthday-adapter/issues/detail?id=32

dschuermann commented 11 years ago

From domschuermann@gmail.com on January 07, 2013 22:57:25 At the moment the version on F-Droid is outdated. I am already auto-detecting date format in all versions but made some workarounds for known android problems with Time in newer versions (after 1.3). So this problem should be fixed in 1.6

dschuermann commented 11 years ago

From domschuermann@gmail.com on January 07, 2013 23:04:48 If they are not fixed, please report back after using 1.6

dschuermann commented 11 years ago

From d.lai...@gmail.com on January 08, 2013 00:37:14 I just built master and found out that it still did not work correctly. Parsing the timestamp string with "yyyyMMdd" will not throw an exception but return some strange dates... When skipping this parsing step and falling back to timestamp directly after "--MM-dd" the adapter works for me.

From the SimpleDateFormat doc: "If parsing succeeds, then the index of pos is updated to the index after the last character used (parsing does not necessarily use all characters up to the end of the string), and the parsed date is returned."

So checking if the whole string has been used for parsing is one option to fix this. (Or just checking the string length...) Unfortunately I don't have time to write and test a proper patch right now...

Debug output of parsing gone wrong: 01-08 01:16:56.601 10140 10150 D Birthday Adapter: Event Date String 627868800000 could not be parsed with yyyy-MM-dd! Falling back to --MM-dd! 01-08 01:16:56.601 10140 10150 D Birthday Adapter: Event Date String 627868800000 could not be parsed with --MM-dd! Falling back to yyyyMMdd! 01-08 01:16:56.601 10140 10150 D Birthday Adapter: Event Date String 627868800000 was parsed as Sun Nov 26 00:00:00 GMT+02:00 8473 01-08 01:16:56.601 10140 10150 D Birthday Adapter: Event Year: 8473

dschuermann commented 11 years ago

From domschuermann@gmail.com on January 08, 2013 10:58:58 Many many thanks for reporting back and testing the newest version.

I will think about a proper fix for this.

dschuermann commented 11 years ago

From domschuermann@gmail.com on January 14, 2013 15:25:53 Fixed in 1.7. Should appear soon on Google Play.