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) 3.0.1 (2016-02-05)
------------------ ------------------

View File

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

View File

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

View File

@ -42,7 +42,8 @@
angular.extend(Card, { angular.extend(Card, {
$$resource: new Resource(Settings.activeUser('folderURL') + 'Contacts', Settings.activeUser()), $$resource: new Resource(Settings.activeUser('folderURL') + 'Contacts', Settings.activeUser()),
$timeout: $timeout, $timeout: $timeout,
$gravatar: Gravatar $gravatar: Gravatar,
$Preferences: Preferences
}); });
// Initialize categories from user's defaults // Initialize categories from user's defaults
Preferences.ready().then(function() { Preferences.ready().then(function() {
@ -170,6 +171,9 @@
this.$omit(), this.$omit(),
{ action: action }) { action: action })
.then(function(data) { .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 // Make a copy of the data for an eventual reset
_this.$shadowData = _this.$omit(true); _this.$shadowData = _this.$omit(true);
return data; return data;
@ -281,18 +285,6 @@
return fullname.join(' '); 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() { Card.prototype.$isCard = function() {
return this.c_component == 'vcard'; return this.c_component == 'vcard';
}; };
@ -468,6 +460,7 @@
}); });
if (_this.birthday) { if (_this.birthday) {
_this.birthday = new Date(_this.birthday * 1000); _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 // Make a copy of the data for an eventual reset
_this.$shadowData = _this.$omit(true); _this.$shadowData = _this.$omit(true);