server_datetime.py 482 B

1234567891011121314151617181920
  1. # -*- coding: utf-8 -*-
  2. from openerp.http import request
  3. from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, DEFAULT_SERVER_DATE_FORMAT
  4. from pytz import timezone
  5. from datetime import datetime
  6. '''
  7. '''
  8. def get_timezone():
  9. return timezone(request.context['tz'])
  10. '''
  11. '''
  12. def get_datetime():
  13. return datetime.now(get_timezone()).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
  14. '''
  15. '''
  16. def get_date():
  17. return datetime.now(get_timezone()).strftime(DEFAULT_SERVER_DATE_FORMAT)