Commit e8696b04 authored by Damien Picard's avatar Damien Picard
Browse files

sun_position: UTC zone as float

parent e79295c6
......@@ -113,10 +113,11 @@ class SunPosProperties(PropertyGroup):
min=1, max=366, default=1,
update=sun_update)
UTC_zone: IntProperty(
UTC_zone: FloatProperty(
name="UTC zone",
description="Time zone: Difference from Greenwich, England in hours",
min=-12, max=12, default=0,
precision=1,
min=-14.0, max=13, step=50, default=0.0,
update=sun_update)
time: FloatProperty(
......
......@@ -240,22 +240,19 @@ def update_time(context):
sun.UTC_zone = sun_props.UTC_zone
def format_time(the_time, UTC_zone, daylight_savings, longitude):
hh = str(int(the_time))
min = (the_time - int(the_time)) * 60
sec = int((min - int(min)) * 60)
mm = "0" + str(int(min)) if min < 10 else str(int(min))
ss = "0" + str(sec) if sec < 10 else str(sec)
def format_time(the_time, daylight_savings, longitude, UTC_zone=None):
if UTC_zone is not None:
if daylight_savings:
UTC_zone += 1
the_time -= UTC_zone
zone = UTC_zone
if daylight_savings:
zone += 1
gt = int(the_time) - zone
the_time %= 24
gt = str(gt % 24)
hh = int(the_time)
mm = (the_time - int(the_time)) * 60
ss = int((mm - int(mm)) * 60)
return ("Local: " + hh + ":" + mm + ":" + ss,
"UTC: " + gt + ":" + mm + ":" + ss)
return ("%02i:%02i:%02i" % (hh, mm, ss))
def format_hms(the_time):
......
......@@ -263,20 +263,23 @@ class SUNPOS_PT_Panel(bpy.types.Panel):
col.separator()
col = flow.column(align=True)
lt, ut = format_time(sp.time,
sp.UTC_zone,
p.show_daylight_savings and sp.use_daylight_savings,
sp.longitude)
col.prop(sp, "time")
col.prop(sp, "UTC_zone")
if p.show_daylight_savings:
col.prop(sp, "use_daylight_savings", text="Daylight Savings")
col.separator()
lt = format_time(sp.time,
p.show_daylight_savings and sp.use_daylight_savings,
sp.longitude)
ut = format_time(sp.time,
p.show_daylight_savings and sp.use_daylight_savings,
sp.longitude,
sp.UTC_zone)
col = flow.column(align=True)
col.alignment = 'CENTER'
col.label(text=lt, icon='TIME')
col.label(text=" " + ut, icon='PREVIEW_RANGE')
col.label(text="Local: " + lt, icon='TIME')
col.label(text=" UTC: " + ut, icon='PREVIEW_RANGE')
col.separator()
col = flow.column(align=True)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment