@@ -2414,26 +2414,32 @@ public static String getDownloadStatus (TdApi.File file, int downloadedRes, bool
2414
2414
2415
2415
public static CharSequence getBirthdate (@ NonNull TdApi .Birthdate birthdate , boolean includeAge , boolean isSelf ) {
2416
2416
Calendar c = Calendar .getInstance ();
2417
+ c .setTimeInMillis (0 );
2417
2418
c .set (Calendar .DAY_OF_MONTH , birthdate .day );
2418
2419
c .set (Calendar .MONTH , birthdate .month - 1 );
2420
+ int birthDayOfThisYear = -1 ;
2419
2421
String date ;
2420
2422
if (birthdate .year != 0 ) {
2421
2423
c .set (Calendar .YEAR , birthdate .year );
2422
2424
date = dateYearShort (c );
2425
+
2426
+ Calendar now = DateUtils .getNowCalendar ();
2427
+ now .set (Calendar .DAY_OF_MONTH , birthdate .day );
2428
+ now .set (Calendar .MONTH , birthdate .month - 1 );
2429
+ birthDayOfThisYear = now .get (Calendar .DAY_OF_YEAR );
2423
2430
} else {
2424
2431
date = dateShort (c );
2425
2432
}
2426
2433
int ageYears = -1 ;
2427
2434
int daysTillBirthday = 0 ;
2428
2435
if (birthdate .year != 0 ) {
2429
2436
Calendar now = DateUtils .getNowCalendar ();
2430
- ageYears = now .get (Calendar .YEAR ) - c . get ( Calendar . YEAR ) ;
2437
+ ageYears = now .get (Calendar .YEAR ) - birthdate . year ;
2431
2438
int today = now .get (Calendar .DAY_OF_YEAR );
2432
- int birthday = c .get (Calendar .DAY_OF_YEAR );
2433
- if (today < birthday ) {
2439
+ if (today < birthDayOfThisYear ) {
2434
2440
ageYears --;
2435
2441
}
2436
- daysTillBirthday = birthday - today ;
2442
+ daysTillBirthday = birthDayOfThisYear - today ;
2437
2443
}
2438
2444
if (includeAge && ageYears > 0 ) {
2439
2445
CharSequence age ;
0 commit comments