Using time.localtime() vs RTC.datetime()

Hello,
I was working on some code and I noticed the usage of both time.localtime() and RTC.datetime() to get the current date. The code is supposed to set the date of the internal rtc on power on.

### timeutil module ###
import machine, pyb

class Rtc:
    def __init__(self):
        # initialise RTC object
        self.rtc = pyb.RTC()
        # set rtc from user defined date and time only on power on
        if (machine.reset_cause() != machine.DEEPSLEEP_RESET):
            self.rtc.datetime(cfg.START_DATETIME)
        
    def datetime(self):
        return self.rtc.datetime() # returns a tuple (year, month, day, weekday, hours, minutes, seconds, subseconds)

    
rtc = Rtc()

clock = time.clock()

def datetime():
    return rtc.datetime()

Is there any reason to use one over the other to get the current date ? If not I don’t think I need to keep my Rtc object.

It’s going to be the same. modtime.c for each port just calls the HAL layer for the port to get the current RTC time.