api.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # -*- coding: utf-8 -*-
  2. """
  3. Provides the default implementation of :class:`ArrowFactory <arrow.factory.ArrowFactory>`
  4. methods for use as a module API.
  5. """
  6. from __future__ import absolute_import
  7. from arrow.factory import ArrowFactory
  8. # internal default factory.
  9. _factory = ArrowFactory()
  10. def get(*args, **kwargs):
  11. """ Calls the default :class:`ArrowFactory <arrow.factory.ArrowFactory>` ``get`` method.
  12. """
  13. return _factory.get(*args, **kwargs)
  14. get.__doc__ = _factory.get.__doc__
  15. def utcnow():
  16. """ Calls the default :class:`ArrowFactory <arrow.factory.ArrowFactory>` ``utcnow`` method.
  17. """
  18. return _factory.utcnow()
  19. utcnow.__doc__ = _factory.utcnow.__doc__
  20. def now(tz=None):
  21. """ Calls the default :class:`ArrowFactory <arrow.factory.ArrowFactory>` ``now`` method.
  22. """
  23. return _factory.now(tz)
  24. now.__doc__ = _factory.now.__doc__
  25. def factory(type):
  26. """ Returns an :class:`.ArrowFactory` for the specified :class:`Arrow <arrow.arrow.Arrow>`
  27. or derived type.
  28. :param type: the type, :class:`Arrow <arrow.arrow.Arrow>` or derived.
  29. """
  30. return ArrowFactory(type)
  31. __all__ = ["get", "utcnow", "now", "factory"]