server_date.py 460 B

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