Return-Path: X-Original-To: apmail-cordova-issues-archive@minotaur.apache.org Delivered-To: apmail-cordova-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AD03E18A31 for ; Thu, 3 Dec 2015 19:31:19 +0000 (UTC) Received: (qmail 75744 invoked by uid 500); 3 Dec 2015 19:31:11 -0000 Delivered-To: apmail-cordova-issues-archive@cordova.apache.org Received: (qmail 75639 invoked by uid 500); 3 Dec 2015 19:31:11 -0000 Mailing-List: contact issues-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@cordova.apache.org Received: (qmail 75001 invoked by uid 99); 3 Dec 2015 19:31:11 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Dec 2015 19:31:11 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 2732D2C1F74 for ; Thu, 3 Dec 2015 19:31:11 +0000 (UTC) Date: Thu, 3 Dec 2015 19:31:11 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@cordova.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CB-8115) incorrect birthday saved to phonebook using Contacts Plugin MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CB-8115?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15038412#comment-15038412 ] ASF GitHub Bot commented on CB-8115: ------------------------------------ Github user jasongin commented on a diff in the pull request: https://github.com/apache/cordova-plugin-contacts/pull/95#discussion_r46598691 --- Diff: src/android/ContactAccessorSdk5.java --- @@ -1854,6 +1859,39 @@ public boolean remove(String id) { return (result > 0) ? true : false; } + /** + * Gets birthday date from contact JSON object + * @param contact an object to get birthday from + * @return birthday or null, if the field isn't present or + * is malformed in the contact + */ + private Date getBirthday(JSONObject contact) { + try { + Long timestamp = contact.getLong("birthday"); + return new Date(timestamp); + } catch (JSONException e) { + Log.d(LOG_TAG, "Could not get birthday: " + e.getMessage()); --- End diff -- As a general good practice, instead of appending the exception message to the error string, pass the exception object to the log method overload that takes a throwable as the third parameter. The exception message and stack trace will then be printed to logcat. Also, it would be more appropriate to use Log.e() instead of Log.d() for this kind of unexpected error. > incorrect birthday saved to phonebook using Contacts Plugin > ----------------------------------------------------------- > > Key: CB-8115 > URL: https://issues.apache.org/jira/browse/CB-8115 > Project: Apache Cordova > Issue Type: Bug > Components: Plugin Contacts > Affects Versions: 4.0.0 > Environment: Android and IOS > Reporter: Kiran Jain > Assignee: Vladimir Kotikov > Priority: Minor > Labels: Android, IOS, birthday, reproduced, triaged > > We are facing an issue while trying to add birthday to Contact while using Cordova for android while adding a new contact to the phonebook > following is part of the code > contact = navigator.contacts.create({ > "displayName": displayname > }); > // store contact name > var contactName = new ContactName(); > contactName.familyName = lastname; > contactName.givenName = firstname > contact.name = contactName; > contact.birthday = new Date("16 May 1984"); > // save the contact > contact.save(); > With above code, when data is viewed in android phone, the birthday is save as 29-12-6731 instead of expected 16-May-1984 > we have tried all possible combinations of date entry viz: 16-May-1984 ; 16/May/1984 ; 16/5/1984 ; new date(1984,05,16) > but all in vain the results are the same. > also need to know how to save anniversary date > when using this plugin for IOS, the date saved is 15-May-1984 (1 day less than expected). -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org For additional commands, e-mail: issues-help@cordova.apache.org