datetime.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2024, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <cudf/types.hpp>
20 #include <cudf/utilities/export.hpp>
21 
23 #include <rmm/resource_ref.hpp>
24 
25 #include <memory>
26 
32 namespace CUDF_EXPORT cudf {
33 namespace datetime {
50 std::unique_ptr<cudf::column> extract_year(
53 
64 std::unique_ptr<cudf::column> extract_month(
67 
78 std::unique_ptr<cudf::column> extract_day(
81 
92 std::unique_ptr<cudf::column> extract_weekday(
95 
106 std::unique_ptr<cudf::column> extract_hour(
107  cudf::column_view const& column,
109 
120 std::unique_ptr<cudf::column> extract_minute(
121  cudf::column_view const& column,
123 
134 std::unique_ptr<cudf::column> extract_second(
135  cudf::column_view const& column,
137 
151 std::unique_ptr<cudf::column> extract_millisecond_fraction(
152  cudf::column_view const& column,
154 
168 std::unique_ptr<cudf::column> extract_microsecond_fraction(
169  cudf::column_view const& column,
171 
185 std::unique_ptr<cudf::column> extract_nanosecond_fraction(
186  cudf::column_view const& column,
188  // end of group
206 std::unique_ptr<cudf::column> last_day_of_month(
207  cudf::column_view const& column,
209 
220 std::unique_ptr<cudf::column> day_of_year(
221  cudf::column_view const& column,
223 
254 std::unique_ptr<cudf::column> add_calendrical_months(
255  cudf::column_view const& timestamps,
256  cudf::column_view const& months,
258 
289 std::unique_ptr<cudf::column> add_calendrical_months(
290  cudf::column_view const& timestamps,
291  cudf::scalar const& months,
293 
307 std::unique_ptr<cudf::column> is_leap_year(
308  cudf::column_view const& column,
310 
323 std::unique_ptr<cudf::column> days_in_month(
324  cudf::column_view const& column,
326 
339 std::unique_ptr<cudf::column> extract_quarter(
340  cudf::column_view const& column,
342 
347 enum class rounding_frequency : int32_t {
348  DAY,
349  HOUR,
350  MINUTE,
351  SECOND,
352  MILLISECOND,
353  MICROSECOND,
354  NANOSECOND
355 };
356 
367 std::unique_ptr<cudf::column> ceil_datetimes(
368  cudf::column_view const& column,
369  rounding_frequency freq,
371 
382 std::unique_ptr<cudf::column> floor_datetimes(
383  cudf::column_view const& column,
384  rounding_frequency freq,
386 
397 std::unique_ptr<cudf::column> round_datetimes(
398  cudf::column_view const& column,
399  rounding_frequency freq,
401  // end of group
403 
404 } // namespace datetime
405 } // 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:48
An owning class to represent a singular value.
Definition: scalar.hpp:49
std::unique_ptr< cudf::column > extract_quarter(cudf::column_view const &column, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Returns the quarter of the date.
std::unique_ptr< cudf::column > add_calendrical_months(cudf::column_view const &timestamps, cudf::scalar const &months, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
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::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Round datetimes down to the nearest multiple of the given frequency.
std::unique_ptr< cudf::column > round_datetimes(cudf::column_view const &column, rounding_frequency freq, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Round datetimes to the nearest multiple of the given frequency.
std::unique_ptr< cudf::column > ceil_datetimes(cudf::column_view const &column, rounding_frequency freq, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Round datetimes up to the nearest multiple of the given frequency.
std::unique_ptr< cudf::column > is_leap_year(cudf::column_view const &column, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Check if the year of the given date is a leap year.
std::unique_ptr< cudf::column > days_in_month(cudf::column_view const &column, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Extract the number of days in the month.
std::unique_ptr< cudf::column > day_of_year(cudf::column_view const &column, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Computes the day number since the start of the year from the datetime and returns an int16_t cudf::co...
rounding_frequency
Fixed frequencies supported by datetime rounding functions ceil, floor, round.
Definition: datetime.hpp:347
std::unique_ptr< cudf::column > last_day_of_month(cudf::column_view const &column, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Computes the last day of the month in datetime type and returns a TIMESTAMP_DAYS cudf::column.
std::unique_ptr< cudf::column > extract_microsecond_fraction(cudf::column_view const &column, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Extracts microsecond fraction from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > extract_nanosecond_fraction(cudf::column_view const &column, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Extracts nanosecond fraction from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > extract_minute(cudf::column_view const &column, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Extracts minute from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > extract_millisecond_fraction(cudf::column_view const &column, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Extracts millisecond fraction from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > extract_year(cudf::column_view const &column, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Extracts year from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > extract_day(cudf::column_view const &column, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Extracts day from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > extract_month(cudf::column_view const &column, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Extracts month from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > extract_weekday(cudf::column_view const &column, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Extracts a weekday from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > extract_second(cudf::column_view const &column, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Extracts second from any datetime type and returns an int16_t cudf::column.
std::unique_ptr< cudf::column > extract_hour(cudf::column_view const &column, rmm::device_async_resource_ref mr=rmm::mr::get_current_device_resource())
Extracts hour from any datetime type and returns an int16_t cudf::column.
cuda::mr::async_resource_ref< cuda::mr::device_accessible > device_async_resource_ref
device_memory_resource * get_current_device_resource()
cuDF interfaces
Definition: aggregation.hpp:35
Type declarations for libcudf.