w3resource

Python Arrow Module: Create a new Arrow object, representing the "ceiling" of the timespan of the Arrow object in a given timeframe using arrow module

Arrow Module: Exercise-13 with Solution

Write a Python program to create a new Arrow object, representing the "ceiling" of the timespan of the Arrow object in a given timeframe using arrow module. The timeframe can be any datetime property like day, hour, minute.

Sample Solution:

Python Code:

import arrow
print(arrow.utcnow())
print("Hour ceiling:")
print(arrow.utcnow().ceil('hour'))
print("\nMinute ceiling:")
print(arrow.utcnow().ceil('minute'))
print("\nSecond ceiling:")
print(arrow.utcnow().ceil('second')) 

Sample Output:

2019-06-01T11:08:59.961000+00:00
Hour ceiling:
2019-06-01T11:59:59.999999+00:00

Minute ceiling:
2019-06-01T11:08:59.999999+00:00

Second ceiling:
2019-06-01T11:08:59.999999+00:00

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to create a datetime object, converted to the specified timezone using arrow module.
Next: Write a Python program to create a ctime formatted representation of the date and time using arrow module.

What is the difficulty level of this exercise?

Test your Python skills with w3resource's quiz



Python: Tips of the Day

Python: Chaining Of Comparison Operators

Example:

n = 20
test = 1 < n < 30
print(test)

Output:

True

Example:

test = 1 > n <= 9
print(test)

Output:

False