datetime.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2019-2025, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
8 #include <cudf/types.hpp>
10 #include <cudf/utilities/export.hpp>
12 
13 #include <rmm/cuda_stream_view.hpp>
14 
15 #include <memory>
16 
22 namespace CUDF_EXPORT cudf {
23 namespace datetime {
33 enum class datetime_component : uint8_t {
34  YEAR,
35  MONTH,
36  DAY,
37  WEEKDAY,
38  HOUR,
39  MINUTE,
40  SECOND,
41  MILLISECOND,
42  MICROSECOND,
43  NANOSECOND
44 };
45 
58 std::unique_ptr<cudf::column> extract_datetime_component(
60  datetime_component component,
63  // end of group
82 std::unique_ptr<cudf::column> last_day_of_month(
86 
98 std::unique_ptr<cudf::column> day_of_year(
102 
134 std::unique_ptr<cudf::column> add_calendrical_months(
135  cudf::column_view const& timestamps,
136  cudf::column_view const& months,
139 
171 std::unique_ptr<cudf::column> add_calendrical_months(
172  cudf::column_view const& timestamps,
173  cudf::scalar const& months,
176 
191 std::unique_ptr<cudf::column> is_leap_year(
192  cudf::column_view const& column,
195 
209 std::unique_ptr<cudf::column> days_in_month(
210  cudf::column_view const& column,
213 
227 std::unique_ptr<cudf::column> extract_quarter(
228  cudf::column_view const& column,
231 
236 enum class rounding_frequency : int32_t {
237  DAY,
238  HOUR,
239  MINUTE,
240  SECOND,
241  MILLISECOND,
242  MICROSECOND,
243  NANOSECOND
244 };
245 
257 std::unique_ptr<cudf::column> ceil_datetimes(
258  cudf::column_view const& column,
259  rounding_frequency freq,
262 
274 std::unique_ptr<cudf::column> floor_datetimes(
275  cudf::column_view const& column,
276  rounding_frequency freq,
279 
291 std::unique_ptr<cudf::column> round_datetimes(
292  cudf::column_view const& column,
293  rounding_frequency freq,
296  // end of group
298 
299 } // namespace datetime
300 } // namespace CUDF_EXPORT cudf
A non-owning, immutable view of device data as a column of elements, some of which may be null as ind...
A container of nullable device data as a column of elements.
Definition: column.hpp:36
An owning class to represent a singular value.
Definition: scalar.hpp:40
std::unique_ptr< cudf::column > add_calendrical_months(cudf::column_view const ×tamps, cudf::scalar const &months, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Adds or subtracts a number of months from the datetime type and returns a timestamp column that is of...
std::unique_ptr< cudf::column > floor_datetimes(cudf::column_view const &column, rounding_frequency freq, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Round datetimes down to the nearest multiple of the given frequency.
std::unique_ptr< cudf::column > last_day_of_month(cudf::column_view const &column, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Computes the last day of the month in datetime type and returns a TIMESTAMP_DAYS cudf::column.
std::unique_ptr< cudf::column > days_in_month(cudf::column_view const &column, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Extract the number of days in the month.
std::unique_ptr< cudf::column > round_datetimes(cudf::column_view const &column, rounding_frequency freq, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Round datetimes to the nearest multiple of the given frequency.
std::unique_ptr< cudf::column > is_leap_year(cudf::column_view const &column, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Check if the year of the given date is a leap year.
std::unique_ptr< cudf::column > day_of_year(cudf::column_view const &column, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Computes the day number since the start of the year from the datetime and returns an int16_t cudf::co...
std::unique_ptr< cudf::column > extract_quarter(cudf::column_view const &column, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Returns the quarter of the date.
rounding_frequency
Fixed frequencies supported by datetime rounding functions ceil, floor, round.
Definition: datetime.hpp:236
std::unique_ptr< cudf::column > ceil_datetimes(cudf::column_view const &column, rounding_frequency freq, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Round datetimes up to the nearest multiple of the given frequency.
datetime_component
Types of datetime components that may be extracted.
Definition: datetime.hpp:33
std::unique_ptr< cudf::column > extract_datetime_component(cudf::column_view const &column, datetime_component component, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Extracts the specified datetime component from any datetime type and returns an int16_t cudf::column.
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
rmm::device_async_resource_ref get_current_device_resource_ref()
Get the current device memory resource reference.
detail::cccl_async_resource_ref< cuda::mr::resource_ref< cuda::mr::device_accessible > > device_async_resource_ref
cuDF interfaces
Definition: host_udf.hpp:26
Type declarations for libcudf.