Handle birthday dates before 1970

pull/198/head
Francis Lachapelle 2016-02-05 16:39:33 -05:00
parent 9f7c205da9
commit 9e905b43ff
4 changed files with 20 additions and 17 deletions

9
NEWS
View File

@ -1,3 +1,12 @@
3.0.2 (2016-02-DD)
------------------
Enhancements
-
Bug fixes
- [web] handle birthday dates before 1970
3.0.1 (2016-02-05)
------------------

View File

@ -349,7 +349,8 @@ static Class SOGoContactGCSEntryK = Nil;
NSMutableArray *units, *categories;
NSCalendarDate *date;
id o;
unsigned int i, year, month, day, seconds;
int seconds;
unsigned int i, year, month, day;
[card setNWithFamily: [attributes objectForKey: @"c_sn"]
given: [attributes objectForKey: @"c_givenname"]
@ -365,7 +366,7 @@ static Class SOGoContactGCSEntryK = Nil;
forKey: @""];
seconds = [[NSString stringWithFormat: @"%@", [attributes objectForKey: @"birthday"]] intValue];
if (seconds > 0)
if (seconds != 0)
{
date = [NSCalendarDate dateWithTimeIntervalSince1970: seconds];
year = [date yearOfCommonEra];

View File

@ -73,14 +73,14 @@
</header>
<section class="msg-body">
<div class="pseudo-input-container" ng-show="editor.card.$birthday().length">
<div class="pseudo-input-container" ng-show="editor.card.birthday">
<div class="key">
<label class="pseudo-input-label">
<var:string label:value="Birthday"/>
</label>
</div>
<div class="pseudo-input-field">
<span>{{editor.card.$birthday()}}</span>
<span>{{editor.card.$birthday}}</span>
</div>
</div>

View File

@ -42,7 +42,8 @@
angular.extend(Card, {
$$resource: new Resource(Settings.activeUser('folderURL') + 'Contacts', Settings.activeUser()),
$timeout: $timeout,
$gravatar: Gravatar
$gravatar: Gravatar,
$Preferences: Preferences
});
// Initialize categories from user's defaults
Preferences.ready().then(function() {
@ -170,6 +171,9 @@
this.$omit(),
{ action: action })
.then(function(data) {
// Format birthdate
if (_this.birthday)
_this.$birthday = Card.$Preferences.$mdDateLocaleProvider.formatDate(_this.birthday);
// Make a copy of the data for an eventual reset
_this.$shadowData = _this.$omit(true);
return data;
@ -281,18 +285,6 @@
return fullname.join(' ');
};
/**
* @function $birthday
* @memberof Card.prototype
* @returns the formatted birthday object
*/
Card.prototype.$birthday = function() {
if (this.birthday) {
return [this.birthday.getFullYear(), this.birthday.getMonth() + 1, this.birthday.getDate()].join('/');
}
return '';
};
Card.prototype.$isCard = function() {
return this.c_component == 'vcard';
};
@ -468,6 +460,7 @@
});
if (_this.birthday) {
_this.birthday = new Date(_this.birthday * 1000);
_this.$birthday = Card.$Preferences.$mdDateLocaleProvider.formatDate(_this.birthday);
}
// Make a copy of the data for an eventual reset
_this.$shadowData = _this.$omit(true);