Latest Uploads
Rpg Potion Sprites

Pakz

Super Shap ... ration Kit

Andy_A

Platdude Spotting

Jayenkai

Nom nom nom

Jayenkai

Rainbow Trout

Pakz

King Salmon

Pakz

Code Snippets > Timing ( Created 26 March 2016 | Last Edited 26 March 2016)

naturaltime.py by HoboBen | No Votes
human readable time deltas for Python
Written in
Python
Given a Python datetime, generate a nice helpful string, relative to right now, like:

'tomorrow at 7:00 am'
'just now'
'about 42 minutes ago'

-->

Gist

Latest Comments

Posted : Saturday, 26 March 2016, 04:08
Jayenkai


Looks useful.
I'm surprised something like that isn't already part of the whole datetime thing. From the look of your code, datetime seems fairly comprehensive.

Homepage : http://AGameAWeek.com
Posted : Sunday, 27 March 2016, 01:19
HoboBen


Datetimes in python, and in particular timedeltas, are super super handy

There is this module which can humanize all sorts of things for different languages, but it was overkill for me!

https://pypi.python.org/pypi/humanize

-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 554|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Latest Posts
Buy Zelda
Jayenkai Sat 16:28
Repetitive Blogging
rskgames Fri 10:04
TinyBlocks
spinal Fri 06:46
Arduboy Owners Club
spinal Fri 02:30
AGameAWeek : 2017 - Part One
Jayenkai Thu 13:11
A New Korg Gadget!
Jayenkai Thu 12:30
SNES Mini?
rychan Thu 07:11
Steampunk Lamp
Jayenkai Wed 06:05
Finishing Off
rockford Tue 08:20
Weather in Games
rychan Tue 07:26
More

Latest Items
Showcase : Quadoban
rskgames Fri 10:11
Blog : My Arduino experience.
steve_ancell Wed 17:02
Showcase : Roguelike Explorer
Pakz Fri 06:59
Showcase : Infinitron
Jayenkai Mon 07:50
News : Newsletter #311
Jayenkai Thu 17:27
Link : Super Shapes Exploration Kit
Andy_A Thu 11:09
Dev-Diary : Sensitive - Arduboy!
rychan Thu 17:27
Snippet : Skylines
steve_ancell Tue 14:25
Dev-Diary : PS2 to N64 Adapter
spinal Sun 10:49
Link : Vector Tutorials/Help page.
Pakz Thu 23:00
Blog : mini project
spinal Sun 10:13
Showcase : Blockman Returns
Jayenkai Fri 03:04
Snippet : Wall Tracing on Random Maps (rpg)
rskgames Wed 22:48
Snippet : Path Following
Pakz Mon 16:25
More

Who's Online
rskgames
Sun, at 01:13
Pakz
Sat, at 20:05
shroom_monk
Sat, at 19:24
Jayenkai
Sat, at 19:16
steve_ancell
Sat, at 17:56
rockford
Sat, at 16:23
Andy_A
Sat, at 14:01
spinal
Sat, at 13:37
9572AD
Fri, at 16:58
rychan
Fri, at 04:50
Link to this page
Site : Jayenkai 2006-Infinity | MudChat's origins, BBCode's former life, Image Scaler.