How to change rain gauge calculating time period

I have a rain gauge system using IR obstacle sensor, and i found the code for calculating rain intensity in hourly and daily. Now i want to change the calculating period to ‘per 15 minutes’, what should I change from the code?
here’s the code:

#include "RTClib.h"
#include <Wire.h>
#define RainPin 2                         // The Rain input is connected to digital pin 2 on the arduino


bool bucketPositionA = false;             // one of the two positions of tipping-bucket               
const double bucketAmount = 0.00277;      // 1 tip sensor ini mewakili 0.00277 inchi of rain
 
double dailyRain = 0.0;                   // rain accumulated for the day
double hourlyRain = 0.0;                  // rain accumulated for one hour
double dailyRain_till_LastHour = 0.0;     // rain accumulated for the day till the last hour          
bool first;                               // as we want readings of the (MHz) loops only at the 0th moment 

RTC_Millis rtc;                           // software RTC time


void setup(void) {
  Serial.begin(9600);                            // start the serial port
  rtc.begin(DateTime(__DATE__, __TIME__));       // start the RTC
  pinMode(RainPin, INPUT);                       // set the Rain Pin as input.
  delay(4000);                                   // wait the serial monitor 
  Serial.println("Rain Gauge Ready !!");         // rain gauge measured per 1 hour           
  Serial.println("execute calculations once per hour !!");
}


void loop(void){
  DateTime now = rtc.now();
    
  // ++++++++++++++++++++++++ Count the bucket tips ++++++++++++++++++++++++++++++++
  if ((bucketPositionA==false)&&(digitalRead(RainPin)==LOW)){
    bucketPositionA=true;
    dailyRain+=bucketAmount;                               // update the daily rain
  }
  
  if ((bucketPositionA==true)&&(digitalRead(RainPin)==HIGH)){
    bucketPositionA=false;  
  } 
  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  
  if(now.minute() != 0) first = true;                     // after the first minute is over, be ready for next read
  
  if(now.minute() == 0 && first == true){
 
    hourlyRain = (dailyRain - dailyRain_till_LastHour);      // calculate the last hour's rain 
    dailyRain_till_LastHour = dailyRain;                   // update the rain till last hour for next calculation
    
    // fancy display for humans to comprehend
    Serial.println();
    Serial.print(now.hour());
    Serial.print(":");
    Serial.print(now.minute());
    Serial.print("     :  Rain in last 1 hour = ");
    Serial.print(hourlyRain,3); 
    Serial.print(" inches atau ");
    Serial.print(hourlyRain*2.54*10,3);  //50 tip 0.241mm
    Serial.println(" mm"); 
    Serial.println();
    
    first = false;                                        // execute calculations only once per hour
  }
  
  if(now.hour()== 0) {
    dailyRain = 0.0;                                      // clear daily-rain at midnight
    dailyRain_till_LastHour = 0.0;                        // we do not want negative rain at 01:00
  }  
}                                                        // end of loop

Since the entire program logic is based around hourly intervals, you need to change it rather completely. I would suggest abandon the hours/minutes approach and use minutes past midnight.

minutes_past_midnight = 60*now.hour() + now.minute();

Detect 15 minute intervals using the integer remainder operator (%)

if (minutes_past_midnight % 15 == 0) {  //do something at a 15 minute mark

Of course, you will need a state variable to detect when that 15 minute mark is reached.

This will probably work but I can’t test it:

#include "RTClib.h"
#include <Wire.h>
#define RainPin 2                         // The Rain input is connected to digital pin 2 on the arduino


bool bucketPositionA = false;             // one of the two positions of tipping-bucket
const double bucketAmount = 0.00277;      // 1 tip sensor ini mewakili 0.00277 inchi of rain

double dailyRain = 0.0;                   // rain accumulated for the day
double qtrHourlyRain = 0.0;                  // rain accumulated for one hour
double dailyRain_till_LastQtrHour = 0.0;     // rain accumulated for the day till the last hour
bool first;                               // as we want readings of the (MHz) loops only at the 0th moment

RTC_Millis rtc;                           // software RTC time


void setup(void) {
  Serial.begin(9600);                            // start the serial port
  rtc.begin(DateTime(__DATE__, __TIME__));       // start the RTC
  pinMode(RainPin, INPUT);                       // set the Rain Pin as input.
  delay(4000);                                   // wait the serial monitor
  Serial.println("Rain Gauge Ready !!");         // rain gauge measured per 1 hour
  Serial.println("execute calculations once per hour !!");
}


void loop(void) {
  DateTime now = rtc.now();

  // ++++++++++++++++++++++++ Count the bucket tips ++++++++++++++++++++++++++++++++
  if ((bucketPositionA == false) && (digitalRead(RainPin) == LOW)) {
    bucketPositionA = true;
    dailyRain += bucketAmount;                             // update the daily rain
  }

  if ((bucketPositionA == true) && (digitalRead(RainPin) == HIGH)) {
    bucketPositionA = false;
  }
  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

  if (now.minute()%15 != 0) first = true;                    // after the first minute is over, be ready for next read

  if (now.minute()%15 == 0 && first == true) {

    qtrHourlyRain = (dailyRain - dailyRain_till_LastQtrHour);      // calculate the last qtr hour's rain
    dailyRain_till_LastQtrHour = dailyRain;                   // update the rain till last qtr hour for next calculation

    // fancy display for humans to comprehend
    Serial.println();
    Serial.print(now.hour());
    Serial.print(":");
    Serial.print(now.minute());
    Serial.print("     :  Rain in last 15 min = ");
    Serial.print(qtrHourlyRain, 3);
    Serial.print(" inches atau ");
    Serial.print(qtrHourlyRain * 2.54 * 10, 3); //50 tip 0.241mm
    Serial.println(" mm");
    Serial.println();

    first = false;                                        // execute calculations only once per hour
  }

  if (now.hour() == 0) {
    dailyRain = 0.0;                                      // clear daily-rain at midnight
    dailyRain_till_LastQtrHour = 0.0;                        // we do not want negative rain at 01:00
  }
}                                                        // end of loop