MobilityDB  1.0
Functions
period.h File Reference

Basic routines for time periods composed of two TimestampTz values and two Boolean values stating whether the bounds are inclusive or not. More...

#include <postgres.h>
#include <lib/stringinfo.h>
#include <catalog/pg_type.h>
#include "timetypes.h"
Include dependency graph for period.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

Datum period_in (PG_FUNCTION_ARGS)
 Input function for periods. More...
 
Datum period_out (PG_FUNCTION_ARGS)
 Output function for periods. More...
 
Datum period_recv (PG_FUNCTION_ARGS)
 Receive function for periods. More...
 
Datum period_send (PG_FUNCTION_ARGS)
 Send function for periods. More...
 
void period_write (const Period *p, StringInfo buf)
 Send function for periods (internal function) More...
 
Periodperiod_read (StringInfo buf)
 Receive function for periods (internal function) More...
 
char * period_to_string (const Period *p)
 Returns the string representation of the period. More...
 
Datum period_constructor2 (PG_FUNCTION_ARGS)
 Construct a period from the two arguments. More...
 
Datum period_constructor4 (PG_FUNCTION_ARGS)
 Construct a period from the four arguments. More...
 
Datum timestamp_to_period (PG_FUNCTION_ARGS)
 Cast the timestamp value as a period. More...
 
Datum period_to_tstzrange (PG_FUNCTION_ARGS)
 Convert the period as a tstzrange value. More...
 
Datum tstzrange_to_period (PG_FUNCTION_ARGS)
 Convert the tstzrange value as a period. More...
 
Datum period_lower (PG_FUNCTION_ARGS)
 Returns the lower bound value. More...
 
Datum period_upper (PG_FUNCTION_ARGS)
 Returns the upper bound value. More...
 
Datum period_lower_inc (PG_FUNCTION_ARGS)
 Returns true if the lower bound value is inclusive. More...
 
Datum period_upper_inc (PG_FUNCTION_ARGS)
 Returns true if the upper bound value is inclusive. More...
 
Datum period_shift (PG_FUNCTION_ARGS)
 Shift the period by the interval. More...
 
Periodperiod_shift_internal (const Period *p, const Interval *start)
 Shift the period by the interval (internal function) More...
 
void period_shift_tscale (Period *result, const Interval *start, const Interval *duration)
 Shift and/or scale the period by the two intervals (internal function) More...
 
Datum period_duration (PG_FUNCTION_ARGS)
 Returns the duration of the period. More...
 
Datum period_eq (PG_FUNCTION_ARGS)
 Returns true if the first period is equal to the second one. More...
 
Datum period_ne (PG_FUNCTION_ARGS)
 Returns true if the first period is different from the second one. More...
 
Datum period_cmp (PG_FUNCTION_ARGS)
 Returns -1, 0, or 1 depending on whether the first period is less than, equal, or greater than the second one. More...
 
Datum period_lt (PG_FUNCTION_ARGS)
 Returns true if the first period is less than the second one. More...
 
Datum period_le (PG_FUNCTION_ARGS)
 Returns true if the first period is less than or equal to the second one. More...
 
Datum period_ge (PG_FUNCTION_ARGS)
 Returns true if the first period is greater than or equal to the second one. More...
 
Datum period_gt (PG_FUNCTION_ARGS)
 Returns true if the first period is greater than the second one. More...
 
bool period_eq_internal (const Period *p1, const Period *p2)
 Returns true if the first period is equal to the second one (internal function) More...
 
bool period_ne_internal (const Period *p1, const Period *p2)
 Returns true if the first period is different from the second one (internal function) More...
 
int period_cmp_internal (const Period *p1, const Period *p2)
 Returns -1, 0, or 1 depending on whether the first period is less than, equal, or greater than the second one (internal function) More...
 
bool period_lt_internal (const Period *p1, const Period *p2)
 Returns true if the first period is less than the second one (internal function) More...
 
bool period_le_internal (const Period *p1, const Period *p2)
 Returns true if the first period is less than or equal to the second one (internal function) More...
 
bool period_ge_internal (const Period *p1, const Period *p2)
 Returns true if the first period is greater than or equal to the second one (internal function) More...
 
bool period_gt_internal (const Period *p1, const Period *p2)
 Returns true if the first period is greater than the second one (internal function) More...
 
void period_deserialize (const Period *p, PeriodBound *lower, PeriodBound *upper)
 Deconstruct the period. More...
 
int period_cmp_bounds (const PeriodBound *lower, const PeriodBound *upper)
 Compare two period boundary points, returning <0, 0, or >0 according to whether b1 is less than, equal to, or greater than b2. More...
 
Periodperiod_make (TimestampTz lower, TimestampTz upper, bool lower_inc, bool upper_inc)
 Construct a period from the bounds. More...
 
void period_set (Period *p, TimestampTz lower, TimestampTz upper, bool lower_inc, bool upper_inc)
 Set the period from the argument values. More...
 
Periodperiod_copy (const Period *p)
 Returns a copy of the period. More...
 
float8 period_to_secs (TimestampTz t1, TimestampTz t2)
 Returns the number of seconds of the period as a float8 value. More...
 
Interval * period_duration_internal (const Period *p)
 Returns the duration of the period (internal function) More...
 
Period ** periodarr_normalize (Period **periods, int count, int *newcount)
 Normalize an array of periods. More...
 
Periodperiod_super_union (const Period *p1, const Period *p2)
 Returns the smallest period that contains p1 and p2. More...
 
void period_expand (Period *p1, const Period *p2)
 Expand the first period with the second one. More...
 
int period_bound_qsort_cmp (const void *a1, const void *a2)
 Comparison function for sorting period bounds. More...
 

Detailed Description

Basic routines for time periods composed of two TimestampTz values and two Boolean values stating whether the bounds are inclusive or not.