DateRange Library

This library provides functions to create various DateRanges. All functions return Dates in UTC.

All datetime parameters are assumed to be UTC unless otherwise specified (e.g. by supplying a timezone object in the datetime constructor)

 For more information about the Python datetime library, click here.

Import

To use this library and its functions, you must use the import line at the beginning of your Base Python code.

import DateRange

 

Custom range 

DateRange.date_range(start, end)

Represents a time range from start to end dates.

  • Credit cost: 0
  • Parameters:
    • startdatetime Start of DateRange
    • enddatetime End of DateRange
  • Returns: DateRange
  • Example:
      • Sample Code:

        import DateRange
        from datetime import datetime, timedelta
        
        now_dt = datetime.now()
        in_5_days_dt = now_dt + timedelta(days = 5)
        
        custom = DateRange.date_range(now_dt, in_5_days_dt)
      • Return Value:

        2020-07-13T23:08:16.152Z -> 2020-07-18T23:08:16.152Z

 

This second

DateRange.this_second()

Represents a time range from the start of this second until now.

  • Credit cost: 0
  • Parameters: None
  • Returns: DateRange
  • Example:
      • Sample Code:

        import DateRange
         this_second = DateRange.this_second()
      • Return Value:

        2020-07-13T23:08:16.000Z -> 2020-07-13T23:08:16.153Z

 

One second from X

DateRange.one_second_from(date_time)

Represents a time range of one second starting from date_time.

  • Credit cost: 0
  • Parameters:
    • date_timedatetime Start of DateRange
  • Returns: DateRange
  • Example:
      • Sample Code:

        import DateRange
        from datetime import datetime, timedelta
        
        now_dt = datetime.now()
        
        one_second_from_now = DateRange.one_second_from(now_dt)
      • Return Value:

        2020-07-13T23:08:16.152Z -> 2020-07-13T23:08:17.152Z

 

This minute

DateRange.this_minute()

Represents a time range from the start of this minute until now.

  • Credit cost: 0
  • Parameters: None
  • Returns: DateRange
  • Example:
      • Sample Code:

        import DateRange
         this_minute = DateRange.this_minute()
      • Return Value:

        2020-07-13T23:08:00.154Z -> 2020-07-13T23:08:16.154Z

 

One minute from X

DateRange.one_minute_from(date_time)

Represents a time range of one minute starting from date_time.

  • Credit cost: 0
  • Parameters:
    • date_timedatetime Start of DateRange
  • Returns: DateRange
  • Example:
      • Sample Code:

        import DateRange
        from datetime import datetime, timedelta
        
        now_dt = datetime.now()
        
        one_minute_from_now = DateRange.one_minute_from(now_dt)
      • Return Value:

        2020-07-13T23:08:16.152Z -> 2020-07-13T23:09:16.152Z

 

This hour

DateRange.this_hour()

Represents a time range from the start of this hour until now.

  • Credit cost: 0
  • Parameters: None
  • Returns: DateRange
  • Example:
      • Sample Code:

        import DateRange
         this_hour = DateRange.this_hour()
      • Return Value:

        2020-07-13T23:00:00.154Z -> 2020-07-13T23:08:16.154Z

 

One hour from X

NOTE - This function is under development and is not working at this time.

DateRange.one_hour_from(date_time)

Represents a time range of one hour starting from date_time.

  • Credit cost: 0
  • Parameters:
    • date_timedatetime Start of DateRange
  • Returns: DateRange
  • Example:
      • Sample Code:

        import DateRange
        from datetime import datetime, timedelta
        
        now_dt = datetime.now()
        
        one_hour_from_now = DateRange.one_hour_from(now_dt)
      • Return Value:

        2020-07-13T23:08:16.152Z -> 2020-07-14T00:08:16.152Z

 

Today

DateRange.today()

Represents a time range from the start of today (UTC time) until now.

  • Credit cost: 0
  • Parameters: None
  • Returns: DateRange
  • Example:
      • Sample Code:

        import DateRange
         today = DateRange.today()
      • Return Value:

        2020-07-13T00:00:00.000Z -> 2020-07-13T23:08:16.155Z

 

One day from X

DateRange.one_day_from(date_time)

Represents a time range of one day starting from date_time.

  • Credit cost: 0
  • Parameters:
    • date_timedatetime Start of DateRange
  • Returns: DateRange
  • Example:
      • Sample Code:

        import DateRange
        from datetime import datetime, timedelta
        
        now_dt = datetime.now()
        
        one_day_from_now = DateRange.one_day_from(now_dt)
      • Return Value:

        2020-07-13T23:08:16.152Z -> 2020-07-14T23:08:16.152Z

 

This week 

DateRange.this_week()

Represents a time range from the start of this week (UTC time) until now.

  • Credit cost: 0
  • Parameters: None
  • Returns: DateRange
  • Example:
      • Sample Code:

        import DateRange
         this_week = DateRange.this_week()
      • Return Value:

        2020-07-13T00:00:00.155Z -> 2020-07-13T23:08:16.155Z

 

One week from X 

DateRange.one_week_from(date_time)

Represents a time range of one week starting from date_time.

  • Credit cost: 0
  • Parameters:
    • date_timedatetime Start of DateRange
  • Returns: DateRange
  • Example:
      • Sample Code:

        import DateRange
        from datetime import datetime, timedelta
        
        now_dt = datetime.now()
        
        one_week_from_now = DateRange.one_week_from(now_dt)
      • Return Value:

        2020-07-13T23:08:16.152Z -> 2020-07-20T23:08:16.152Z