{ "info": { "author": "Garfield.Yang", "author_email": "ymy1019@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5" ], "description": "django-unixtimestampfield\n===========================\n\n.. image:: https://img.shields.io/travis/myyang/django-unixtimestampfield.svg\n :target: https://travis-ci.org/myyang/django-unixtimestampfield\n\n.. image:: https://img.shields.io/pypi/v/django-unixtimestampfield.svg\n :target: https://pypi.python.org/pypi/django-unixtimestampfield/\n\n.. image:: https://coveralls.io/repos/myyang/django-unixtimestampfield/badge.svg?service=github\n :target: https://coveralls.io/github/myyang/django-unixtimestampfield\n\nProvide a custom field that is stored as float (UTC POSIX timestamp) and used as datetime instance.\n\n\nRequirements\n------------\n\n* Database that supports **Float** type is compatible\n* Python2.7, 3.4 with Django 1.8, 1.9\n \n**Note**: Since the 1.8 is LTS version, I choose to support from 1.8. \n`SubClassing will be removed in 2.0`_ , so I handle *from_db_value()* only.\nIf you could help version <= 1.7, welcome~~ :D\n\n.. _`SubClassing will be removed in 2.0`: https://github.com/django/django/blob/1.8/django/db/models/fields/subclassing.py#L21\n\nInstall\n-------\n\n.. code-block:: shell\n\n pip install django-unixtimestampfield\n\nUsage\n-----\n\n\nUsed in model as following:\n\n.. code-block:: python\n\n from django.db import models\n \n from unixtimestampfield.fields import UnixTimeStampField\n\n class ModelA(models.Model):\n\n created = UnixTimeStampField(auto_now_add=True)\n modified = UnixTimeStampField(auto_now=True)\n str_ini = UnixTimeStampField(default='0.0')\n float_ini = UnixTimeStampField(default=0.0)\n int_ini = UnixTimeStampField(default=0.0)\n dt_ini = UnixTimeStampField(default=timezone.now)\n num_field = UnixTimeStampField(use_numeric=True, default=0.0)\n\n\nOperation exmpale:\n\n.. code-block:: python\n\n >>> m = modelA.objects.create()\n >>> m.created\n datetime.datetime(2015, 9, 2, 10, 41, 41, 937257, tzinfo=)\n >>> m.int_ini\n datetime.datetime(1970, 1, 1, 0, 0, tzinfo=)\n >>> m.int_ini = 3\n >>> m.save()\n >>> m.int_ini\n datetime.datetime(1970, 1, 1, 0, 3, tzinfo=)\n >>> m.num_field\n 0.0\n\nField Options\n~~~~~~~~~~~~~\n\n* **auto_now**: Set to True for updating while saving, just like DatetimeField\n* **auto_now_add**: set to True for updating while creating, just like DatetimeField\n* **round_to**: percision (*num*) of round(value, *num*), default: **6**\n* **use_float**: **DEPRECATED in v0.3**, see use_numeric\n* **use_numeric**: set as True that instance attribute would be numeric, default as **False**\n\n\nDjango settings\n~~~~~~~~~~~~~~~\n\n\nIf `USE_TZ` is set to `False`, return current datetime (in UTC timezone) info without **tzinfo** while accessing attribute. \n\nExample:\n\n.. code-block:: python\n\n # In settings.py\n USE_TZ = False\n\n >>> m = modelA.objects.create()\n >>> m.created\n datetime.datetime(2015, 9, 2, 10, 41, 41, 937257)\n\nTemplate Tags\n~~~~~~~~~~~~~\n\nLoad template tags:\n\n.. code-block:: html\n\n {% load unixtimestampfield %}\n\n\nTwo django template filter tags are available:\n\n* **to_datetime**: Filter value as datetime\n* **to_timestamp**: Filter value as timestamp\n\n\nTricky Sub-middleware\n~~~~~~~~~~~~~~~~~~~~~\n\nDue to value is stored as float, it's hard for recognizing and leads to this tricky middleware.\n\nHere are 3 modes to show data:\n\n* **usf_default**: Show data by default, according to use_numeric option of field. This is also default setting.\n* **usf_datetime**: Always convert to datetime object\n* **usf_timestamp**: Always convert to timestamp\n\nUse `USF_FORMAT` to indicate display police in `settings.py`. Let's see examples.\n\nAssume ModelB as:\n\n.. code-block:: python\n\n class ModelB(models.Model):\n\n num_field = UnixTimeStampField(use_numeric=True, default=0.0)\n dt_field = UnixTimeStampField(default=0.0)\n\nThen getting field value what you want:\n\n.. code-block:: python\n\n >>> m = ModelB()\n # with USF_FORMAT='usf_default' in settings.py \n >>> m.num_field, m.dt_field\n (0.0, datetime.datetime(1970, 1, 1, 0, 0))\n\n # with USF_FORMAT='usf_datetime' in settings.py \n >>> m.num_field, m.dt_field\n (datetime.datetime(1970, 1, 1, 0, 0), datetime.datetime(1970, 1, 1, 0, 0))\n\n # with USF_FORMAT='usf_timestamp' in settings.py \n >>> m.num_field, m.dt_field\n (0.0, 0.0)\n\n\nVersion\n-------\n\n*v0.3.9* -- Fix packages including in setup.py\n\n*v0.3.8* -- Bugs fixed: Apply submiddleware to auto_now field and check format in submiddleware\n\n*V0.3.7* -- Check minimum value.\n\n*V0.3.6* -- Fix timezone problem. All records are stored UTC timezone and convert while retrive.\n\n*V0.3.5.1* -- Integer compatibility and fix timezone problem\n\n*V0.3.5* -- Parse time format: YYYY-mm-dd HH:MM:SS[.FFFFFF]\n\n*V0.3.4* -- Bugs fixed.\n\n*V0.3.3* -- Add sub-middleware and template tags\n\n*v0.3* -- Add ordinal time field and change field options **use_float** to **use_numeric**!!!\n\n*v0.2* -- Handle formfield and add options while init\n\n*v0.1* -- Added UnixTimeStampField \n\nLICENSE\n-------\n\nMIT", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/myyang/django-unixtimestampfield", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "django-unixtimestampfield", "package_url": "https://pypi.org/project/django-unixtimestampfield/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-unixtimestampfield/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/myyang/django-unixtimestampfield" }, "release_url": "https://pypi.org/project/django-unixtimestampfield/0.3.9/", "requires_dist": null, "requires_python": null, "summary": "Django Unix timestamp (POSIX type) field", "version": "0.3.9" }, "last_serial": 3136461, "releases": { "0.3.3": [ { "comment_text": "", "digests": { "md5": "4dc61aeac125aab560e4cfefa0b0eb8b", "sha256": "e387e68b70f81881e50ac09bacef948a5aaa406d98740567b9d8dc76bdce2bf4" }, "downloads": -1, "filename": "django-unixtimestampfield-0.3.3.tar.gz", "has_sig": false, "md5_digest": "4dc61aeac125aab560e4cfefa0b0eb8b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6617, "upload_time": "2015-10-02T07:28:10", "url": "https://files.pythonhosted.org/packages/7e/a8/01ce92124ad829c079e2f2ef9f7f0e194eb451345f59c713d7aa5b9b8142/django-unixtimestampfield-0.3.3.tar.gz" } ], "0.3.4": [ { "comment_text": "", "digests": { "md5": "0eef88729a449bfc33a1e3cefaf9bcc9", "sha256": "2f37392d3d2d6e7dd4846d0f3bbc63543f922c50520479a8fc5ac16fb17084b8" }, "downloads": -1, "filename": "django-unixtimestampfield-0.3.4.tar.gz", "has_sig": false, "md5_digest": "0eef88729a449bfc33a1e3cefaf9bcc9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6698, "upload_time": "2015-11-04T08:36:59", "url": "https://files.pythonhosted.org/packages/a1/75/65a77e176d8519679acf0e44282175fefe52acf5eac1ac1d1692f3c16a25/django-unixtimestampfield-0.3.4.tar.gz" } ], "0.3.5": [ { "comment_text": "", "digests": { "md5": "56212fcc0987a60fe9ebeebbd1ccfdeb", "sha256": "7bdd049ed16e37f320ccafe14a993fe62b25d78afb6038ede9e918250abb7986" }, "downloads": -1, "filename": "django-unixtimestampfield-0.3.5.tar.gz", "has_sig": false, "md5_digest": "56212fcc0987a60fe9ebeebbd1ccfdeb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7004, "upload_time": "2015-12-18T07:48:30", "url": "https://files.pythonhosted.org/packages/51/7c/7f409f635dcb9de523b282a1d0e17283d28a380721ecf24965f179fbeb7d/django-unixtimestampfield-0.3.5.tar.gz" } ], "0.3.5.1": [ { "comment_text": "", "digests": { "md5": "011abd262d4ac357bf0c6cd2bf0932f4", "sha256": "891a957a41bee850967e30414069511cebb1f6a4eccec284dc40f44aa225e6a5" }, "downloads": -1, "filename": "django-unixtimestampfield-0.3.5.1.tar.gz", "has_sig": false, "md5_digest": "011abd262d4ac357bf0c6cd2bf0932f4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8024, "upload_time": "2015-12-21T11:27:56", "url": "https://files.pythonhosted.org/packages/10/a7/967aa372f94a55928ca27cfe84dc4221abc28cbb83a91c14bcce1dc8ae64/django-unixtimestampfield-0.3.5.1.tar.gz" } ], "0.3.6": [ { "comment_text": "", "digests": { "md5": "3413f421ab9b594c9f7201c23aa13576", "sha256": "8d883f5bb89b1885fa61a457b5282820048e83d9d9263c496df96d82d16c7938" }, "downloads": -1, "filename": "django-unixtimestampfield-0.3.6.tar.gz", "has_sig": false, "md5_digest": "3413f421ab9b594c9f7201c23aa13576", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8445, "upload_time": "2015-12-22T04:34:57", "url": "https://files.pythonhosted.org/packages/72/4d/25080defb1b011166f56496577c8d5fdb8cfbb5a5a1c15d20a5d573220ef/django-unixtimestampfield-0.3.6.tar.gz" } ], "0.3.7": [ { "comment_text": "", "digests": { "md5": "59b05dd45b06ff802fc3df451ee6b6b5", "sha256": "d742347864cc9703c42b19664d141b29b138098b05b14bbb2526fff62fdd8130" }, "downloads": -1, "filename": "django-unixtimestampfield-0.3.7.tar.gz", "has_sig": false, "md5_digest": "59b05dd45b06ff802fc3df451ee6b6b5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8854, "upload_time": "2015-12-24T07:51:37", "url": "https://files.pythonhosted.org/packages/00/42/ecf7fabe0513b6bdd7cdf904dfac1b68d43077b42d1899f34c205a303ff3/django-unixtimestampfield-0.3.7.tar.gz" } ], "0.3.8": [ { "comment_text": "", "digests": { "md5": "4ddd8e4ac308e0c30f758f6526553be2", "sha256": "e20ce375e2e1a8a4a8cfa9e3872195ef25f9f8ba7e14a9c10e473ae09f24f044" }, "downloads": -1, "filename": "django-unixtimestampfield-0.3.8.tar.gz", "has_sig": false, "md5_digest": "4ddd8e4ac308e0c30f758f6526553be2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9157, "upload_time": "2016-01-22T04:07:51", "url": "https://files.pythonhosted.org/packages/37/a7/7342c2167dc4a8d7608a6024d6784d9af96b2f9ce895a82579c7525cbff2/django-unixtimestampfield-0.3.8.tar.gz" } ], "0.3.9": [ { "comment_text": "", "digests": { "md5": "4ec53c32eb9109285774f9014ef7a501", "sha256": "b2c98e471e568edcdb78c40a41c2d7f451daf1bea4ea207711d7f9a441e8a282" }, "downloads": -1, "filename": "django-unixtimestampfield-0.3.9.tar.gz", "has_sig": false, "md5_digest": "4ec53c32eb9109285774f9014ef7a501", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9514, "upload_time": "2016-04-11T05:35:25", "url": "https://files.pythonhosted.org/packages/4b/27/e55376ca1a93f416c26f5db488390d9f9f8530a8663ab8773fd0c504e75b/django-unixtimestampfield-0.3.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4ec53c32eb9109285774f9014ef7a501", "sha256": "b2c98e471e568edcdb78c40a41c2d7f451daf1bea4ea207711d7f9a441e8a282" }, "downloads": -1, "filename": "django-unixtimestampfield-0.3.9.tar.gz", "has_sig": false, "md5_digest": "4ec53c32eb9109285774f9014ef7a501", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9514, "upload_time": "2016-04-11T05:35:25", "url": "https://files.pythonhosted.org/packages/4b/27/e55376ca1a93f416c26f5db488390d9f9f8530a8663ab8773fd0c504e75b/django-unixtimestampfield-0.3.9.tar.gz" } ] }