Here are the examples of the python api django.utils.timezone.get_current_timezone.zone taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
0
View Complete Implementation : utils.py
Copyright MIT License
Author : learningequality
Copyright MIT License
Author : learningequality
def perform_ping(started, server=DEFAULT_SERVER_URL):
url = urljoin(server, "/api/v1/pingback")
instance, _ = InstanceIDModel.get_or_create_current_instance()
language = get_device_setting("language_id", "")
try:
timezone = get_current_timezone().zone
except Exception:
timezone = ""
data = {
"instance_id": instance.id,
"version": kolibri.__version__,
"mode": conf.OPTIONS["Deployment"]["RUN_MODE"],
"platform": instance.platform,
"sysversion": instance.sysversion,
"database_id": instance.database.id,
"system_id": instance.system_id,
"node_id": instance.node_id,
"language": language,
"timezone": timezone,
"uptime": int((datetime.datetime.now() - started).total_seconds() / 60),
"timestamp": localtime(),
"installer": installation_type(),
}
logger.debug("Pingback data: {}".format(data))
jsondata = dump_zipped_json(data)
response = requests.post(url, data=jsondata, timeout=60)
response.raise_for_status()
return json.loads(response.content.decode() or "{}")
0
View Complete Implementation : fields.py
Copyright MIT License
Author : learningequality
Copyright MIT License
Author : learningequality
def create_timezonestamp(value):
if value.tzinfo and hasattr(value.tzinfo, "zone"):
# We have a pytz timezone, we can work with this
tz = value.tzinfo.zone
elif value.tzinfo:
# Got some timezone data, but it's not a pytz timezone
# Let's just astume someone used dateutil parser on a UTC
# ISO format timestamp
# Fixes https://github.com/learningequality/kolibri/issues/1824
tz = pytz.utc
value = value.astimezone(tz)
else:
tz = timezone.get_current_timezone().zone
value = timezone.make_aware(value, timezone.get_current_timezone())
date_time_string = value.astimezone(pytz.utc).strftime(date_time_format)
tz_string = tz_format.format(tz=tz)
value = db_storage_string.format(
date_time_string=date_time_string, tz_string=tz_string
)
return value