Improve handling of a contact's birthday

Fixes #3579
This commit is contained in:
Francis Lachapelle
2016-04-05 22:03:52 -04:00
parent af4aae2019
commit bfd69d3f28
3 changed files with 10 additions and 9 deletions
@@ -470,9 +470,10 @@
_this.refs[i] = new Card(o);
});
if (_this.birthday) {
_this.birthday = new Date(_this.birthday * 1000);
Card.$Preferences.ready().then(function() {
_this.$birthday = Card.$Preferences.$mdDateLocaleProvider.formatDate(_this.birthday);
var dlp = Card.$Preferences.$mdDateLocaleProvider;
_this.birthday = _this.birthday.parseDate(dlp, '%Y-%m-%d');
_this.$birthday = dlp.formatDate(_this.birthday);
});
}
// Mark card as loaded
@@ -510,9 +511,9 @@
// We convert back our birthday object
if (!deep) {
if (card.birthday)
card.birthday = card.birthday.getTime()/1000;
card.birthday = card.birthday.format(Card.$Preferences.$mdDateLocaleProvider, '%Y-%m-%d');
else
card.birthday = 0;
card.birthday = '';
}
return card;