Giter Site home page Giter Site logo

raywire / flask-humanize Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vitalk/flask-humanize

0.0 2.0 0.0 25 KB

Common humanization utilities for Flask applications

Home Page: https://pypi.python.org/pypi/Flask-Humanize

Makefile 0.70% Python 99.30%

flask-humanize's Introduction

Flask Humanize

Provides an interface between Flask web framework and humanize library.

Features

  • Add new filter humanize to jinja environment, which can be easily used for humanize different objects:

    • Integer numbers:

      {{ 12345|humanize('intcomma') }} -> 12,345
      {{ 12345591313|humanize('intword') }} -> 12.3 billion
      {{ 5|humanize('apnumber') }} -> five
    • Floating point numbers:

      {{ 0.3|humanize('fractional') }} -> 1/3
      {{ 1.5|humanize('fractional') }} -> 1 1/2
    • File sizes:

      {{ 1000000|humanize('naturalsize') }} -> 1.0 MB
      {{ 1000000|humanize('naturalsize', binary=True) }} -> 976.6 KiB
    • Date & times:

      {{ datetime.datetime.now()|humanize('naturalday') }} -> today
      {{ datetime.date(2014,4,21)|humanize('naturaldate') }} -> Apr 21 2014
      {{ (datetime.datetime.now() - datetime.timedelta(hours=1))|humanize() }} -> an hour ago
  • Runtime i18n/l10n

    from flask import Flask
    from flask_humanize import Humanize
    
    app = Flask(__name__)
    humanize = Humanize(app)
    
    @humanize.localeselector
    def get_locale():
        return 'ru_RU'
    {{ datetime.datetime.now()|humanize }} -> сейчас
  • In order to use UTC time instead of local time for humanize date and time methods use HUMANIZE_USE_UTC option, which is disabled by default:

    HUMANIZE_USE_UTC = True

Issues

Don't hesitate to open GitHub Issues for any bug or suggestions.

flask-humanize's People

Contributors

vitalk avatar diginikkari avatar nlohmann avatar

Watchers

James Cloos avatar Ryan Wire avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.