nuttx/libs/libc/time/Kconfig
Jukka Laitinen 116a325763 libs/libc/time: Add configuration options for the strftime
This adds 3 configuration options for the lib_strftime, which can be
used to save flash memory when all the formatters are not needed by an
embedded application.

There is always a minimal set of formatters supported:
"%a, %b/%h, %d, %H, %m, %M, %S, %Y, %%". To add on top of that one can
specify:

- LIBC_STRFTIME_C_STANDARD_FORMATS  : All ISO-C conversion specifiers
- LIBC_STRFTIME_POSIX_FORMATS       : Additional posix formats
- LIBC_STRFTIME_NONSTANDARD_FORMATS : Additional GNU nonstandard formats

All of these are enabled by default unless building for CONFIG_DEFAULT_SMALL.
Disabling these options can save over 3KB of flash on an 32-bit
ARM system, when all the format specifiers are not needed.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-06-04 14:29:33 +08:00

106 lines
3.4 KiB
Text

#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
menu "Time/Time Zone Support"
config LIBC_STRFTIME_C_STANDARD_FORMATS
bool "strftime ISO C conversion specifiers"
default !DEFAULT_SMALL
---help---
Enable ISO C strftime conversion specifiers that are not part of
the small always-enabled subset. Disabling this option
removes support for %A, %B, %I, %j, %p, %U, %w, %W, %x, %X, and
%y. The always-enabled subset is %a, %b/%h, %d, %H, %m, %M,
%S, %Y, and %%.
Disabling this option makes strftime smaller, but the implementation
no longer supports all conversion specifiers required by ISO C.
config LIBC_STRFTIME_POSIX_FORMATS
bool "strftime POSIX conversion specifiers"
default !DEFAULT_SMALL
depends on LIBC_STRFTIME_C_STANDARD_FORMATS
---help---
Enable POSIX strftime conversion specifiers beyond ISO C that are
implemented by NuttX. Disabling this option removes support for
%C, %e, %F, %g, %G, %n, %r, %R, %t, %T, %u, %V, and %z.
Enabling this option also enables the ISO C conversion specifiers.
Note that %h is kept in the always-enabled subset as an alias for
%b because it shares the same implementation. Some POSIX
specifiers may be controlled by other options.
config LIBC_STRFTIME_NONSTANDARD_FORMATS
bool "strftime non-standard conversion specifiers"
default !DEFAULT_SMALL
---help---
Enable NuttX/GNU-style strftime conversion specifiers that are not
required by ISO C or POSIX. Disabling this option removes support
for %k, %l, %P, and %s.
config LIBC_LOCALTIME
bool "localtime API call support"
default "n"
depends on !DISABLE_ENVIRON
---help---
localtime API call support
Logic currently depends on file system support with, at a minimum, these
files in the zoneinfo directory: GMT and posixrules. An additional
timezone file is required for any additional, local time zone(s) and the
environment variable TZ must be set to the name of that timezone file
when tzset() is called.
See https://www.iana.org/time-zones . See also libs/libc/zoneinfo
which provides a framework for incorporating the TZ database into a
NuttX build.
if LIBC_LOCALTIME
config LIBC_TZ_MAX_TIMES
int "Maximum number of times in timezone"
default 370
---help---
Timezone files with more than this number of times will not be used
(timecnt).
Warning: Some files in IANA TZ database include many times. The current
posixrules file, for example, has timecnt = 236. The value of
TX_MAX_ITMES in the tzfile.h header file on my Linux system is 370, the
default used here. You may want to reduce this value for a smaller
footprint.
config LIBC_TZ_MAX_TYPES
int "Maximum number of TZ types"
default 20
---help---
Maximum number of local time types. You may want to reduce this value
for a smaller footprint.
config LIBC_TZDIR
string "zoneinfo directory path"
default "/etc/zoneinfo"
---help---
This is the full path to the location where the TZ database is expected
to be found.
config LIBC_ZONEINFO
bool "TZ database"
default n
---help---
Download and build the TZ/Olson database.
if LIBC_ZONEINFO
config LIBC_ZONEINFO_ROMFS
bool "Build ROMFS filesystem"
default n
depends on FS_ROMFS
---help---
Build a mountable ROMFS filesystem containing the TZ/Olson database
endif # LIBC_ZONEINFO
endif # LIBC_LOCALTIME
endmenu # Time/Time Zone Support