@ruanitto/react-native-ntp-sync
Version:
Sync time using NTP servers
25 lines (24 loc) • 848 B
TypeScript
import { Config, Delta, NtpDelta, NtpHistory, NtpServer } from "./types";
import { NtpClientError } from "./error";
export default class NTPSync {
private ntpServers;
private limit;
private tickRate;
private syncTimeout;
private currentIndex;
private tickId;
private historyDetails;
private isOnline;
constructor({ servers, history, syncInterval, syncTimeout, syncOnCreation, autoSync, startOnline }?: Config);
private computeAndUpdate;
setIsOnline(isOnline: boolean): void;
getIsOnline(): boolean;
getDelta: () => Promise<NtpDelta>;
getHistory: () => NtpHistory;
getTime: () => number;
private shiftServer;
startAutoSync: () => void;
stopAutoSync: () => void;
syncTime: () => Promise<boolean>;
}
export { Config, Delta, NtpDelta, NtpHistory, NtpServer, NtpClientError };