Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def convert_to_seconds(timeduration):
- ...
- convert_to_seconds("1h")
- -> 3600
- convert_to_seconds("1d")
- -> 86400
- seconds_per_unit = {"s": 1, "m": 60, "h": 3600, "d": 86400, "w": 604800}
- def convert_to_seconds(s):
- return int(s[:-1]) * seconds_per_unit[s[-1]]
- from datetime import timedelta
- UNITS = {"s":"seconds", "m":"minutes", "h":"hours", "d":"days", "w":"weeks"}
- def convert_to_seconds(s):
- count = int(s[:-1])
- unit = UNITS[ s[-1] ]
- td = timedelta(**{unit: count})
- return td.seconds + 60 * 60 * 24 * td.days
- def f(x, y): pass
- f(5, 6)
- f(x=5, y=6)
- f(y=6, x=5)
- d = {"x": 5, "y": 6}
- f(**d)
- long seconds = TextUtils.parsingStringToTimeInterval("5d").toSeconds();
Add Comment
Please, Sign In to add comment