#include "Adafruit_GFX.h"
#include "Adafruit_SSD1306.h"
#include "RTClib.h"

RTC_DS3231 rtc;

#define SCREEN_WIDTH 128 
#define SCREEN_HEIGHT 64 

#define OLED_RESET -1
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

int a,b,c,d,e,f,g,h,i,start,finish,diff,seconds,minutes,hours;

int time_difference() {
a=8;
b=36;
c=55;

d=11;
e=30;
f=4;

a=a*60; //Hours to minutes
b=(b+a)*60; //Minutes to seconds
start=b+c;//Net seconds 1

d=d*60; //Hours to minutes
e=(e+d)*60; //Minutes to seconds
finish=e+f;//Net seconds 2

diff= finish-start; //Difference of net second 1 and 2

/*To convert back answer to Hours:Minutes:seconds*/

g=diff/60; //Seconds to minutes:

hours = g/60;// hours

minutes = g- (hours*60) ; //minutes 

seconds = diff-(60 * g); //seconds

oled.clearDisplay();
oled.setTextSize(1);
oled.setTextColor(WHITE);
oled.setCursor(4,5);
oled.print("Usage Hours:");
oled.setCursor(8,40);
oled.println(hours);
oled.setCursor(18,40);
oled.println(":");
oled.setCursor(30,40);
oled.println(minutes);
oled.setCursor(45,40);
oled.println(":");
oled.setCursor(55,40);
oled.println(seconds);
oled.display();
delay(2000);
oled.clearDisplay();

}

void setup() {
  Serial.begin(9600);
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  oled.clearDisplay();
}

void loop() {
  time_difference();
}

GND5VSDASCLSQWRTCDS1307+