Uniot Docs
  • Introduction
  • Guides
    • Getting Started
    • Uniot Badge
    • Device Network
  • Foundations
    • Edge Logic Deployment
  • General Concepts
    • Primitives
    • Scripting
  • Platform
    • Dashboard
    • Sandbox
      • Visual Editor
        • Special
        • Logic
        • Math
        • Loops
        • Text
        • Variables
        • Functions
        • Primitives
      • Logger
      • Emulator
      • Control Panel
  • Advanced
    • Uniot Core
      • Scheduler
        • TaskScheduler
        • IExecutor
        • ISchedulerConnectionKit
        • Task
        • SchedulerTask
      • AppKit
        • AppKit
        • LispDevice
        • LispPrimitives
        • TopDevice
      • CBORWrapper
        • CBORObject
        • COSE
        • COSEMessage
        • ICOSESigner
      • Date
        • Date
        • SimpleNTP
      • EventBus
        • EventBus
        • IEventBusConnectionKit
        • DataChannels
        • EventEmitter
        • EventListener
        • EventEntity
        • CallbackEventListener
      • Hardware
        • Button
      • LispWrapper
        • DefaultPrimitives
        • LispHelper
        • PrimitiveExpeditor
        • unLisp
      • MQTTWrapper
        • CallbackMQTTDevice
        • MQTTDevice
        • MQTTKit
        • MQTTPath
      • Network
        • ConfigCaptivePortal
        • NetworkController
        • NetworkScheduler
      • Register
        • GpioRegister
        • ObjectRegister
        • ObjectRegisterRecord
        • Register
        • RegisterManager
        • RegisterManagerProxy
      • Storage
        • CBORStorage
        • CrashStorage
        • Storage
        • WifiStorage
      • Utils
        • Array
        • Bytes
        • ClearQueue
        • IterableQueue
        • LimitedQueue
        • GlobalBufferMemoryManager
        • Map
        • Singleton
        • TypeId
      • Credentials
    • Uniot Lisp
      • Language Description
      • Embedding Instructions
  • API
    • MQTT Convention
Powered by GitBook
On this page
  1. Advanced
  2. Uniot Core
  3. Date

Date

The Date class provides functionalities to synchronize system time with NTP servers, retrieve the current time, and manage time-related events. It ensures that the system maintains accurate time, which is essential for various operations such as logging, scheduling, and data timestamping.

Constructor:

  • Date() Private constructor, initializes the Date instance, sets up NTP callbacks, configures NTP servers, and restores stored time.

Methods:

  • static time_t now() Retrieves the current epoch time.

  • static String getFormattedTime() Returns the current time as a formatted string (e.g., "YYYY-MM-DD HH:MM:SS").

  • bool store() override Stores the current epoch time into persistent CBOR storage.

  • bool restore() override Restores the epoch time from CBOR storage and sets the system time accordingly.

  • void execute(short _) override Executes the store operation, typically called after successful time synchronization to persist the updated epoch time.

  • void forceSync() Forces a synchronization with NTP servers to update the system time immediately, bypassing scheduled synchronization intervals.

Private Methods:

  • void _timeSyncCallback() Callback function invoked upon successful time synchronization. Executes the store operation and emits a synchronization event.

  • bool _setTime(time_t epoch) Sets the system time to the specified epoch value.

  • void _reconfigure() Configures the NTP settings by specifying the NTP servers to use for time synchronization.

  • time_t _now() Retrieves the current system epoch time.

  • String _getFormattedTime() Generates a formatted time string based on the current system time.

Private Members:

  • SimpleNTP mSNTP Instance of the SimpleNTP class responsible for handling NTP communications and time synchronization.

PreviousDateNextSimpleNTP

Last updated 4 months ago