Arduino - Calculate Person's Age in Years, Months, Days

Here is code I recently used to calculate persons age in Years, Months, and Days on Arduino:

#include "RTClib.h"
RTC_DS3231 rtc; // Using DS3231 Real Time Clock 
DateTime now =; // Current Date and Time
DateTime dob = DateTime(1984,8,16,0,0,0); // Date of Birth (1984.08.16 00:00:00)
int t0 = dob.year() * 12 + dob.month() - 1;
int t = now.year() * 12 + now.month() - 1;
int dm = t - t0;
int Y;
int M;
int D;
//Calculate age in Y/M/D
if( >={
  Y = floor(dm/12);
  M = dm % 12;
  D = -;
else {
  Y = floor(dm/12);
  M = dm % 12;
  DateTime tmp = DateTime(floor(t/12),(t%12)+1,,0,0,0);
  D = (now.unixtime() - tmp.unixtime())/60/60/24;


The WIFI_SERVICE must be looked up on the Application context...


Generating signed APK in Android Studio 2.3 fails with following error:

Error: The WIFI_SERVICE must be looked up on the Application context or memory will leak on devices < Android N. Try changing  to .getApplicationContext()  [WifiManagerLeak]

ListView Pop-Up Context Menu broken in Android 7 (API 24)


ListView context menu pop-up doesn't work properly in Android 7.0 and 7.1 Nougat (API 24 and API 25).

Instead of the full menu appearing in the middle of the screen, it now appears collapsed to a single item and either at the very top or at the very bottom of the screen.

Here is the expected behaviour:

Here is how the context menu looks in Android 7.1.1:

The app uses library and Theme.Holo.Light theme.


Subscribe to receive occasional updates on new posts.
Your email will not be used for any other purpose and you can unsubscribe at any time.
Please wait