Date and Time Operations
Overview
This manual is divided into several sections, each focusing on a specific aspect of the Kognitos Date and Time Library.
Introduction
The Kognitos Date and Time Library provides powerful and intuitive capabilities for handling date and time operations. This library enables users to retrieve the current date and time in various formats, manipulate date strings, and sort dates efficiently using Kognitos' natural language processing capabilities. This section provides an overview of the Kognitos Date and Time Library and outlines the prerequisites for using it effectively.
Prerequisites for Using the Kognitos Date and Time Library
Before you can start using the Kognitos Date and Time Library, there are several prerequisites that need to be met:
- Kognitos Account: You need to have an active Kognitos account. If you do not have one, you can sign up for a Kognitos trial account to get started.
- Basic Understanding of Date and Time Formats: While Kognitos simplifies interactions, having a basic understanding of date and time formats (e.g., "%m/%d/%Y", "%I:%M:%S%p") will help you automate more effectively with Kognitos.
Once these prerequisites are met, you are ready to start leveraging the power of Kognitos to enhance your date and time operations, making them more accessible, efficient, and customizable.
Time and Date Retrieval
Retrieving the Current Date and Time
To interact with date and time using Kognitos, you can use specific commands designed for retrieving the current date, time, year, month, day, and hour. This section outlines the commands required for these operations and provides detailed examples.
Current Date
To retrieve the current date in the format "%m/%d/%Y":
get the current date
Example:
get the current date
This command returns the current date, for example, "04/01/2023".
Current Time
To retrieve the current time in the format "%I:%M:%S%p":
get the current time
Example:
get the current time
This command returns the current time, for example, "02:30:45PM".
Current Year
To retrieve the current year in the format "%Y":
get the current year
Example:
get the current year
This command returns the current year, for example, "2023".
Current Month
To retrieve the current month by name:
get the current month
Example:
get the current month
This command returns the current month, for example, "February".
Current Day
To retrieve the current day by name:
get the current day
Example:
get the current day
This command returns the current day, for example, "Thursday".
Current Hour
To retrieve the current hour in a 12-hour format along with AM/PM:
get the current hour
Example:
get the current hour
This command returns the current hour, for example, "02PM".
Data Manipulation
Filtering Strings into Dates
To filter a list of strings and convert recognized date strings into date objects, you can use the following command:
the strings are "2023-04-01", "not a date", "April 2nd, 2023"
the department's timezone is "UTC"
if the strings is not empty then
filter the strings into the dates
Example:
the strings are "2023-04-01", "not a date", "April 2nd, 2023"
the department's timezone is "UTC"
if the strings is not empty then
filter the strings into the dates
This command filters the list of strings and converts recognized date strings into date objects.
Sorting Dates
To sort a list of dates in ascending order, you can use the following command:
the dates are "2023-01-01", "2022-12-31", "2023-01-02"
sort the dates
Example:
the dates are "2023-01-01", "2022-12-31", "2023-01-02"
sort the dates
This command sorts the list of dates in ascending order.
Common Elements in Examples
- Setting the Department's Timezone: Setting the department's timezone is a common prerequisite for time and date retrieval functions.
- Use of the Verb
get
: The verbget
is prevalent in retrieval operations. - Use of the Verb
filter
andsort
: The verbfilter
is used for converting strings to date objects, andsort
is used for arranging dates in order. - Context Setup: The examples often start with setting up the context or prerequisites (e.g., setting the department's timezone or defining the strings/dates to be manipulated).
By following these guidelines, you can effectively manage date and time operations in Kognitos, from retrieving the current date and time to filtering and sorting date strings as needed.
Glossary of Terms
- Date Object: A data type used to represent dates in a structured format.
- Timezone: A region of the globe that observes a uniform standard time for legal, commercial, and social purposes.
- Date Format: A specific way of representing dates, such as "%m/%d/%Y" for "04/01/2023".
- 12-hour Format: A time format that divides the 24 hours of a day into two periods: AM (from midnight to noon) and PM (from noon to midnight).
Updated 3 months ago