DEV Community

Cover image for Aiotense - Time Processing Tool
DenyS
DenyS

Posted on

 

Aiotense - Time Processing Tool

aiotense - python time parsing tool.

GitHub - https://github.com/Animatea/aiotense

Documentation - https://animatea.github.io/aiotense/

aiotense is a tool that converts a string like "1day1minute 20seconds" into number of seconds or timedelta objects.

import asyncio 
from aiotense import TenseParser  

time_string = "1d2minutes 5 sec"

# <-- Digit parser --> 
digit_parser = TenseParser(TenseParser.DIGIT) 
digit_value = asyncio.run(digit_parser.parse(time_string)) 
# <-- Assertions --> 
assert digit_value == 86525 
Enter fullscreen mode Exit fullscreen mode
  • If you need case insensitivity, you can use resolvers.

  • Custom parsing sequence - custom resolvers.

  • Need to convert result to string? You can write your own converter by inheriting aiotense.application.ports.converters.AbstractConverter.

  • Need to cache the result? Write your own parser by inheriting aiotense.application.ports.parsers.AbstractParser.

aiotense has been designed with maximum flexibility, practicality and user friendliness in mind. I hope our project helped you or you were just interested in seeing it.

Oldest comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.