datetime.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2022, 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 
21 #include <memory>
22 
28 namespace cudf {
29 namespace datetime {
46 std::unique_ptr<cudf::column> extract_year(
48  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
49 
60 std::unique_ptr<cudf::column> extract_month(
62  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
63 
74 std::unique_ptr<cudf::column> extract_day(
76  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
77 
88 std::unique_ptr<cudf::column> extract_weekday(
90  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
91 
102 std::unique_ptr<cudf::column> extract_hour(
103  cudf::column_view const& column,
104  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
105 
116 std::unique_ptr<cudf::column> extract_minute(
117  cudf::column_view const& column,
118  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
119 
130 std::unique_ptr<cudf::column> extract_second(
131  cudf::column_view const& column,
132  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
133  // end of group
151 std::unique_ptr<cudf::column> last_day_of_month(
152  cudf::column_view const& column,
153  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
154 
165 std::unique_ptr<cudf::column> day_of_year(
166  cudf::column_view const& column,
167  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
168 
199 std::unique_ptr<cudf::column> add_calendrical_months(
200  cudf::column_view const& timestamps,
201  cudf::column_view const& months,
202  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
203 
234 std::unique_ptr<cudf::column> add_calendrical_months(
235  cudf::column_view const& timestamps,
236  cudf::scalar const& months,
237  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
238 
252 std::unique_ptr<cudf::column> is_leap_year(
253  cudf::column_view const& column,
254  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
255 
268 std::unique_ptr<cudf::column> days_in_month(
269  cudf::column_view const& column,
270  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
271 
284 std::unique_ptr<cudf::column> extract_quarter(
285  cudf::column_view const& column,
286  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
287 
292 enum class rounding_frequency : int32_t {
293  DAY,
294  HOUR,
295  MINUTE,
296  SECOND,
297  MILLISECOND,
298  MICROSECOND,
299  NANOSECOND
300 };
301 
312 std::unique_ptr<cudf::column> ceil_datetimes(
313  cudf::column_view const& column,
314  rounding_frequency freq,
315  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
316 
327 std::unique_ptr<cudf::column> floor_datetimes(
328  cudf::column_view const& column,
329  rounding_frequency freq,
330  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
331 
342 std::unique_ptr<cudf::column> round_datetimes(
343  cudf::column_view const& column,
344  rounding_frequency freq,
345  rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
346  // end of group
348 
349 } // namespace datetime
350 } // namespace cudf
cudf::column
A container of nullable device data as a column of elements.
Definition: column.hpp:45
cudf::column_view
A non-owning, immutable view of device data as a column of elements, some of which may be null as ind...
Definition: column_view.hpp:300
types.hpp
Type declarations for libcudf.
cudf::datetime::add_calendrical_months
std::unique_ptr< cudf::column > add_calendrical_months(cudf::column_view const &timestamps, cudf::scalar const &months, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Adds or subtracts a number of months from the date time type and returns a timestamp column that is o...
cudf::datetime::extract_quarter
std::unique_ptr< cudf::column > extract_quarter(cudf::column_view const &column, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Returns the quarter of the date.
cudf::datetime::extract_hour
std::unique_ptr< cudf::column > extract_hour(cudf::column_view const &column, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Extracts hour from any date time type and returns an int16_t cudf::column.
cudf::datetime::round_datetimes
std::unique_ptr< cudf::column > round_datetimes(cudf::column_view const &column, rounding_frequency freq, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Round datetimes to the nearest multiple of the given frequency.
cudf::datetime::day_of_year
std::unique_ptr< cudf::column > day_of_year(cudf::column_view const &column, rmm::mr::device_memory_resource *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...
cudf::datetime::is_leap_year
std::unique_ptr< cudf::column > is_leap_year(cudf::column_view const &column, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Check if the year of the given date is a leap year.
cudf::datetime::floor_datetimes
std::unique_ptr< cudf::column > floor_datetimes(cudf::column_view const &column, rounding_frequency freq, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Round datetimes down to the nearest multiple of the given frequency.
cudf::datetime::days_in_month
std::unique_ptr< cudf::column > days_in_month(cudf::column_view const &column, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Extract the number of days in the month.
cudf::datetime::extract_month
std::unique_ptr< cudf::column > extract_month(cudf::column_view const &column, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Extracts month from any date time type and returns an int16_t cudf::column.
cudf::datetime::extract_year
std::unique_ptr< cudf::column > extract_year(cudf::column_view const &column, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Extracts year from any date time type and returns an int16_t cudf::column.
cudf::datetime::extract_weekday
std::unique_ptr< cudf::column > extract_weekday(cudf::column_view const &column, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Extracts day from any date time type and returns an int16_t cudf::column.
cudf::scalar
An owning class to represent a singular value.
Definition: scalar.hpp:46
cudf::datetime::rounding_frequency
rounding_frequency
Fixed frequencies supported by datetime rounding functions ceil, floor, round.
Definition: datetime.hpp:292
cudf
cuDF interfaces
Definition: aggregation.hpp:34
cudf::datetime::extract_day
std::unique_ptr< cudf::column > extract_day(cudf::column_view const &column, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Extracts day from any date time type and returns an int16_t cudf::column.
rmm::mr::device_memory_resource
cudf::datetime::ceil_datetimes
std::unique_ptr< cudf::column > ceil_datetimes(cudf::column_view const &column, rounding_frequency freq, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Round datetimes up to the nearest multiple of the given frequency.
cudf::datetime::extract_minute
std::unique_ptr< cudf::column > extract_minute(cudf::column_view const &column, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Extracts minute from any date time type and returns an int16_t cudf::column.
cudf::datetime::extract_second
std::unique_ptr< cudf::column > extract_second(cudf::column_view const &column, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Extracts second from any date time type and returns an int16_t cudf::column.
cudf::datetime::last_day_of_month
std::unique_ptr< cudf::column > last_day_of_month(cudf::column_view const &column, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Computes the last day of the month in date time type and returns a TIMESTAMP_DAYS cudf::column.