Aptivi - Manual
ProjectsWebsiteBlog
Nitrocid KS - Manual
Nitrocid KS - Manual
  • Welcome!
  • Versions and Compatibility
    • Supported Versions
    • EOL Versions
    • Version Release Notes
      • v0.0.1.x series
      • v0.0.2.x series
      • v0.0.3.x series
      • v0.0.4.x series
      • v0.0.5.x series
        • v0.0.5.0 Beta Versions
      • v0.0.6.x series
        • v0.0.6.0 Beta Versions
      • v0.0.7.x series
        • v0.0.7.0 Beta Versions
      • v0.0.8.x series
      • v0.0.9.x series
      • v0.0.10.x series
      • v0.0.11.x series
      • v0.0.12.x series
      • v0.0.13.x series
      • v0.0.14.x series
      • v0.0.15.x series
      • v0.0.16.x series
      • v0.0.17.x series
      • v0.0.18.x series
      • v0.0.19.x series
      • v0.0.20.x series
      • v0.0.21.x series
      • v0.0.22.x series
      • v0.0.23.x series
      • v0.0.24.x series
      • v0.1.0.x and 0.1.1.x series
      • v0.1.2.x and v0.1.3.x series
    • Compatibility Notes for KS API Revisions
      • Upgrading to API v1.0 series
      • Upgrading to API v1.1 series
      • Upgrading to API v1.2 series
      • Upgrading to API v1.3 series
      • Upgrading to API v2.0 series
      • Upgrading to API v2.1 series
      • Upgrading to API v3.0 series
        • From 0.0.24.x to 0.1.0 Beta 1
        • From 0.1.0 Beta 1 to 0.1.0 Beta 2
        • From 0.1.0 Beta 2 to 0.1.0 Beta 3
        • From 0.1.0 Beta 3 to 0.1.0 RC
        • From 0.1.0 RC to 0.1.0 Final
      • Upgrading to API v3.1 series
  • Installation and Maintenance
    • Installing the Kernel
      • Windows
      • macOS
      • Linux
      • Android
    • Upgrading the Kernel
      • Windows
      • macOS
      • Linux
      • Android
    • Dependency Information
  • Fundamentals
    • What is the Kernel?
    • What is Nitrocid KS?
    • Simulated Kernel Features
      • Extra Features
        • More Networking
          • FTP Client
          • SSH Connection
          • SFTP Client
          • RSS Client
          • HTTP Client
          • Mail Client
        • Games and Amusements
          • Hangman
          • BackRace
          • Meteor
          • Pong
          • Russian Roulette
          • ShipDuet
          • Snaker
          • Solver
          • SpeedPress
          • Wordle
        • More Editors
          • JSON Editor
          • SQL Editor
        • Common Programs
          • Archive
          • Caffeine
          • Calendar
          • Calculator
          • Contacts
          • Dictionary
          • Git Shell
          • Notes
          • Stocks
          • Timers
          • To-do List
          • Unit Converter
          • Weather
        • Docking
        • Language Studio
        • Theme Studio
      • Accounts
        • Groups
        • Permissions
      • Editors
        • Text Editor
        • Hex Editor
      • Shells
        • Commands List
        • Addon Commands List
      • Files and Folders
        • Hashing and Encryption
      • The Nitrocid Homepage
      • Networking
      • Localization
      • Screensavers
      • Lockscreen Widgets
      • Audio Cues
  • Advanced and Power Users
    • Building the Kernel
      • Building on Windows
      • Building on macOS
      • Building on Linux
      • Building on Android
    • Kernel Modifications
      • Building your Mod
      • Analyzing your Mod
        • Text - NKS0001
        • ConsoleBase - NKS0002
        • ConsoleBase - NKS0003
        • ConsoleBase - NKS0004
        • ConsoleBase - NKS0005
        • ConsoleBase - NKS0006
        • ConsoleBase - NKS0007
        • ConsoleBase - NKS0008
        • ConsoleBase - NKS0009
        • Files - NKS0010
        • Files - NKS0011
        • Files - NKS0012
        • Files - NKS0013
        • Files - NKS0014
        • Files - NKS0015
        • Files - NKS0016
        • Files - NKS0017
        • Files - NKS0018
        • Files - NKS0019
        • Files - NKS0020
        • Files - NKS0021
        • Files - NKS0022
        • Files - NKS0023
        • Kernel - NKS0024
        • Kernel - NKS0025
        • Kernel - NKS0026
        • Kernel - NKS0027
        • Kernel - NKS0031
        • Kernel - NKS0032
        • Kernel - NKS0033
        • Kernel - NKS0037
        • Kernel - NKS0038
        • Kernel - NKS0039
        • Kernel - NKS0040
        • Kernel - NKS0041
        • Kernel - NKS0042
        • Kernel - NKS0043
        • Kernel - NKS0052
        • Kernel - NKS0053
        • Languages - NKS0044
        • Languages - NKS0045
        • Languages - NKS0046
        • Network - NKS0051
        • Text - NKS0047
        • Text - NKS0048
        • Text - NKS0049
        • Text - NKS0050
        • Text - NKS0054
        • Text - NKS0055
      • Managing your Mod
        • Inter-Mod Communication
        • Inter-Addon Communication
    • Diagnostics
      • Debugging
        • Local Debugging
        • Remote Debugging
      • Testing
      • Other Diagnostics
    • Bootloader
      • Boot Choices
      • Kernel Environments
      • Custom Boot Styles
    • Inner Workings
      • Kernel Settings
        • Mechanics of Settings App
        • Settings Format
        • Custom Settings
      • Shell Structure
        • Help System
        • Command Parsing
        • Command Information
        • Command Switches
        • Shell History
        • Shell Scripting
        • Shell Presets
        • Extra Shell Features
      • Multilingual Kernel
        • Locale Tools
        • Custom Languages
      • Inner Essentials
        • Kernel Drivers
          • Console Drivers
          • Debug Logger Drivers
          • Encoding Drivers
          • Encryption Drivers
          • Filesystem Drivers
          • Hardware Prober Drivers
          • Input Drivers
          • Network Drivers
          • RNG Drivers
          • Regular Expression Drivers
          • Sorting Drivers
        • Kernel Placeholders
        • The Permissions
        • The Users
        • Kernel Threads
        • Kernel Arguments
        • Kernel Journaling
        • Remote Procedure
        • Nitrocid Filesystem
        • Screensaver Internals
        • Splash Internals
        • Kernel Platform
        • Theme Internals
        • Color Internals
        • Privacy Consents
        • System Notifications
        • MAL and MOTD
        • Progress Handlers
        • Assembly Signing
        • Assembly Reflection
        • Random Number Generation
        • Network Tools
        • Date and Time
        • Mod Manual Pages
      • Miscellaneous APIs
  • Project Dependencies
  • Report an issue
  • Source code
  • API Reference
Powered by GitBook
On this page
  • Time tools
  • Time zones
  • Calendar management API
  • Date conversion API
  • Miscellaneous tools
  • Alarms
  • Renderers
Edit on GitHub
  1. Advanced and Power Users
  2. Inner Workings
  3. Inner Essentials

Date and Time

Date and time tools

Last updated 7 months ago

Nitrocid KS provides an API that allows you to perform date and time operations, like rendering them to a string instance, managing time zones, and starting alarms. This feature is found under the Nitrocid.Kernel.Time namespace, as this feature is crucial for the kernel to be able to tell the current date (today) and the current time (now).

The tools let you perform from the simplest operations, such as getting the current date and time, to the most complex operations, such as converting date and time to other formats, such as the Unix time.

Time tools

The base time/date tools allow you to perform general time and date operations, such as getting remaining time from either the current moment or from the selected moment. These functions allow you to perform this operation easily:

  • GetRemainingTimeFromNow(): Returns a TimeSpan instance that indicates the remaining time from the current moment to the specified amount of milliseconds.

  • GetRemainingTimeFrom(): Returns a TimeSpan instance that indicates the remaining time from the specified moment to the specified amount of milliseconds.

Not only these tools are readily available for you to use, but you can also use this class to get the current date and time in both the local time (KernelDateTime) and the UTC time zone (KernelDateTimeUtc).

Time zones

Nitrocid KS provides a built-in time zone API that allows you to get information about a time zone and convert the time to the equivalent time using the specific time zone. This API is found in the TimeZones class.

If the kernel-wide time zone is enabled, the current kernel time and date changes, depending on your selected kernel-wide time zone. Otherwise, the kernel uses the operating system time and date.

One of the functions that the above class implements is GetZoneTimeString() and its sibling functions, GetZoneTimeTimeString() and GetZoneTimeDateString().

  • The first function returns the full date and time using the specified time zone.

  • The second function returns the time using the specified time zone.

  • The third function returns the date using the specified time zone.

Calendar management API

In addition to providing the calendar command in the addon, the base Nitrocid API provides some of the calendar management APIs to make access to them easier than before. You can now get the calendar straight from the calendar type or its name using the GetCalendar() function from the CalendarTools class.

Additionally, you can use the variant calendar, which uses your culture to define a calendar culture. This can be accessed by calling GetCalendar() with CalendarTypes.Variant as a type.

Additionally, the time and date renderers can be used with the base calendar class instance obtained from the above function. The following calendars can be used:

  • Chinese: zh-CN

  • Gregorian: en-US

  • Hijri: ar

  • Japanese: ja-JP

  • Persian: fa

  • SaudiHijri: ar-SA

  • Taiwanese: zh-TW

  • ThaiBuddhist: th-TH

  • Variant: Your culture as specified by your kernel configuration

It's important to take note of these:

  • While the events can be configured to be a yearly event, such as the Nitrocid KS release anniversary, such events have to be created by hand until the event commands are updated.

  • Although it looks like that you can make your own custom calendar, there are no available methods to register your own calendar. We'll work on it in the next Nitrocid release. For now, use your newly-created instance of your calendar.

Date conversion API

Nitrocid API provides date conversion tools that allow you to change how the date and the time are being represented. For instance, you can translate the date and the time to UNIX time and vice versa.

As for the calendars, you can use the GetDateFromCalendar() function, provided that you have a calendar instance from the GetCalendar() function. Also, you can use the GetDateFromCalendarNoCulture() function for calendars with overridden Calendar property.

Miscellaneous tools

In addition to the above time tools, there are some of the features that use the date and time feature as an essential recipe for their implementation.

Alarms

When it comes to alarms, they are useful to alarm you for something at a specified time. This service and its tools can be accessed via the AlarmTools class.

public static class AlarmTools

You can start an alarm using the StartAlarm() function that lets you specify your alarm ID, your alarm name, and your alarm interval in seconds.

public static void StartAlarm(string alarmId, string alarmName, int alarmValue)

Additionally, you can stop an alarm before it's up using a function defined below:

public static void StopAlarm(int alarmIdx)
public static void StopAlarm(string alarmId)

Renderers

The renderers are essential if you want to get the text form of either the current date and time or the selected date and time. This is to simplify the functions that are used to do the same thing, but in the more coherent form to be able to use it like never before. The following classes are available for you to use in your mods:

  • TimeDateRenderers: This class provides general time and date renderers that use your local time zone to return a text indicating either the current time and date or the selected time and date. You can optionally specify a target date, a target culture/calendar, and a target format type.

  • TimeDateRenderersUtc: This class provides general time and date renderers that use UTC to return a text indicating either the current time and date or the selected time and date. You can optionally specify a target date, a target culture/calendar, and a target format type.

  • TimeDateMiscRenderers: This class provides miscellaneous time and date renderers, including getting a string instance of the remaining time and printing the current date and time to the console.

You can also use one of the constants specified in the TimeDateRenderConstants class as a custom format.

Nitrocid KS provides an option to show the date and time in the upper right corner. If you've enabled this option, you'll be able to see the current date and time there. To enable or to disable this feature, you must open the kernel settings application using the settings command, then Miscellaneous settings > Show Time/Date on Upper Right Corner. Once enabled, you should be able to see the current date and time in the corner as shown in the above picture.

In case the current date and time doesn't show up in the corner, reboot the kernel, and it should show up.

For Linux systems, a check for /usr/share/zoneinfo is performed, and if it doesn't exist, you'll be prompted to install tzdata from your Linux distribution's repository. See the for more information about how to install this package to your system.

In some renderers, you can use the custom date and time formats, as long as they specify a valid syntax to print the date and the time. You can refer to for more information about how to write a valid date and time format.

dependency page
this documentation