-
Notifications
You must be signed in to change notification settings - Fork 13
Query Date Time
FPL provides a couple of functions for querying and constructing calendar date and time values.
A date time is stored in the fplDateTime structure, which holds the Unix epoch (seconds since 1970-01-01), additional milliseconds and the UTC offset in minutes.
Note: Pre-1970 dates are not supported. The epoch field is unsigned and
fplDateTimeCreate() rejects any year below 1970.
For pure delta/profiling measurements, use the functions described in
Time Measurement & Profiling instead.
You can query the current date and time by calling fplDateTimeQuery() and passing a fplDateTimeType value.
Pass fplDateTimeType_UTC to get the time in UTC (+0) or fplDateTimeType_Local to get the local time including the current UTC offset.
// Query the current local date time
now = ();
// Query the current UTC date time
utcNow = ();The returned fplDateTime is not directly human readable - it stores the epoch, milliseconds and UTC offset only.
To get the individual date and time components, use fplFormatDateTime() (see Extract the date and time components).
To break a fplDateTime into its individual fields (year, month, day, hour, etc.), call fplFormatDateTime() .
It returns a fplDateTimeResult, which contains the year, month, day, hour, minute, second and millisecond.
The fplDateTimeType argument controls whether the components are computed in UTC or local time.
now = ();
// Compute the individual components in local time
fields = (now, );
("%04d-%02d-%02d %02d:%02d:%02d.%03d\n",
fields., fields., fields.,
fields., fields., fields., fields.);You can construct a fplDateTime from individual components by calling fplDateTimeCreate() .
It takes the year, month, day, hour, minute, second, millisecond and the UTC offset in minutes.
The result is returned as a fplDateTimeCreationResult. Always check the success field before using the resulting date time.
If the creation fails, the errors field contains a combination of fplDateTimeErrors flags describing which component was invalid.
// Create the date time 2026-05-16 13:45:00.000 in UTC (+0)
result = (2026, 5, 16, 13, 45, 0, 0, 0);
if (result.) {
dateTime = result.;
// Do something with the date time
} else {
if (result. & ) {
// The year was out of range (expected 1970 or higher)
}
}Note: If invalid arguments are passed, an empty date time is returned and
success is set to false.
- The fplDateTime structure is the canonical storage format - convert it with fplFormatDateTime() only when you need the individual fields.
- The utcOffset field is zero when the date time is UTC or +0, otherwise it holds the offset in minutes used to convert back into UTC.
- fplDateTimeQuery() and fplFormatDateTime() are platform functions, while fplDateTimeCreate() is a common function available on all platforms.
- Assertion & Debug
- Atomic operations
- Audio functions
- Clipboard functions
- Console functions
- Constants
- Display/Monitor functions
- Dynamic library loading
- Error Handling
- Files/IO functions
- Function macros
- Hardware Infos
- Input types and functions
- Localization functions
- Logging
- Memory Macros
- Memory functions
- Operating system Infos
- Path functions
- Platform functions
- Session Infos
- Settings & Configurations
- Storage class identifiers
- String functions
- Threading and synchronizations routines
- Timing functions
- Video functions
- Window events
- Window functions
- fplARMCPUCapabilities
- fplAudioChannelMap
- fplAudioDeviceID
- fplAudioDeviceInfo
- fplAudioFormat
- fplAudioSettings
- fplColor32
- fplConditionVariable
- fplConsoleSettings
- fplCPUCapabilities
- fplCPUIDLeaf
- fplDateTime
- fplDateTimeCreationResult
- fplDateTimeResult
- fplDisplayInfo
- fplDisplayMode
- fplDynamicLibraryHandle
- fplEndianess
- fplEvent
- fplFileEntry
- fplFileHandle
- fplFilePermissions
- fplFileTimeStamps
- fplGamepadButton
- fplGamepadData
- fplGamepadEvent
- fplGamepadInfo
- fplGamepadInputBinding
- fplGamepadMapping
- fplGamepadSettings
- fplGamepadState
- fplGamepadStates
- fplGraphicsApiSettings
- fplImageSource
- fplInputBackendMask
- fplInputBackendSupport
- fplInputDevice
- fplInputDeviceGuid
- fplInputSettings
- fplInternalConditionVariable
- fplInternalDynamicLibraryHandle
- fplInternalFileEntryHandle
- fplInternalFileHandle
- fplInternalFileRootInfo
- fplInternalMutexHandle
- fplInternalSemaphoreHandle
- fplInternalSignalHandle
- fplInternalThreadHandle
- fplKeyboardEvent
- fplKeyboardState
- fplLogSettings
- fplLogWriter
- fplLogWriterConsole
- fplLogWriterCustom
- fplMemoryAllocationSettings
- fplMemoryBlock
- fplMemoryInfos
- fplMemorySettings
- fplMouseEvent
- fplMouseState
- fplMutexHandle
- fplOpenGLSettings
- fplOSVersionInfos
- fplSemaphoreHandle
- fplSettings
- fplSignalHandle
- fplSpecificAudioSettings
- fplThreadHandle
- fplThreadParameters
- fplTimestamp
- fplVersionInfo
- fplVideoBackBuffer
- fplVideoRect
- fplVideoRequirements
- fplVideoRequirementsVulkan
- fplVideoSettings
- fplVideoSurface
- fplVideoSurfaceOpenGL
- fplVideoSurfaceVulkan
- fplVideoWindow
- fplVulkanSettings
- fplWindowCallbacks
- fplWindowDropFiles
- fplWindowEvent
- fplWindowPosition
- fplWindowSettings
- fplWindowSize
- fplX86CPUCapabilities