After a lot of searching the web and thinking. I can up with a simple (and now obvious) solution to getting 12hr time from your DS3231 using the DS321.h library (Source: DS3231)
Note: I wrote this code for a tft display but it should work the same for serial of LCD display (I added Serial.begin(9600); and serial to all print lines for simplicity, the code below should work for serial).
Heres the basic code:
#include <DS3231.h>
DS3231 rtc(SDA, SCL);
// Init a Time-data structure
Time t;
void setup(void) {
Serial.begin(9600);
rtc.begin();
}
void loop(void) {
// Get data from the DS3231
t = rtc.getTime();
int Hour = t.hour;
// Time Line
serial.print("TIME: ");
if (Hour <= 12){
serial.print(rtc.getTimeStr());
serial.print(" AM");}
else{
int hour12 = t.hour - 12;
if (hour12 < 10){
serial.print("0");}
serial.print(hour12);
serial.print(':');
if(t.min<10){
serial.print("0");
}
serial.print(t.min, DEC);
serial.print(':');
if(t.sec<10){
serial.print("0");
}
serial.print(t.sec, DEC);
serial.print(" PM");
}
}