Dietpi as local NTP server

I have a Raspberry Pi that only occasionally gets Internet via the router. I want the Pi to run an NTP daemon and act as the primary time source for devices on the local network. When the Pi has Internet access it should use public NTP servers as references; if the Internet is unavailable it should continue serving time to the LAN using its battery‑backed RTC.
(does dietpi save to PI5s onboard clock?)

How to configure the Pi as the LAN’s NTP server so other devices can sync to it.

Use Internet NTP servers when online, but remain the authoritative local source when offline.

Can anybod recommend a configuration for this scenario? Thanks.

You can do this with ntp (and disabling systemd-timesyncd) and a cronjob/systemd-timer to check network connectivity and then writing to hw clock with hwclock command, or you can just use chrony, which handles all of this in one piece of software . It’s ntp-client, ntp-server and handles multiply clock sources with fallbacks etc. pp.

A config for chrony could be

# internet NTP
pool pool.ntp.org iburst maxsources 4

# RTC as base on boot
rtcsync
rtcfile /var/lib/chrony/rtc

# offline fallback
local stratum 10

# allow LAN clients
allow 192.168.1.0/24

# drift file
driftfile /var/lib/chrony/drift

# time correction if necessary
makestep 1.0 3