Hi
I’m trying to convert a datetime to HOY, and i’m looking through the core code but I got stuck at:
return self.timetuple().tm_yday
from
https://www.ladybug.tools/ladybug/docs/_modules/ladybug/dt.html#DateTime
Is there a way to see the source code fully so that I can go from datetime to HOY in one fluent code? I’m trying to run this in Python in an external program so I just want to code behind.
Thanks
Hello, if these are not the droids you are looking for: hopefully they are in the ballpark.
# Ladybug: A Plugin for Environmental Analysis (GPL)
# This file is part of Ladybug.
#
# Copyright (c) 2021, Ladybug Tools.
# You should have received a copy of the GNU General Public License
# along with Ladybug; If not, see <http://www.gnu.org/licenses/>.
#
# @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>
"""
Calculate hour of the year from month, day, hour, minute.
-
Args:
_month_: Integer for month (1-12).
_day_: Integer for day (1-31).
_hour_: Integer for hour (0-23).
_minute_: Integer for minute (0-59).
Returns:
This file has been truncated. show original
# coding=utf-8
"""Ladybug datetime."""
from __future__ import division
from datetime import datetime, date, time
MONTHNAMES = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
'Oct', 'Nov', 'Dec')
class DateTime(datetime):
"""Create Ladybug Date time.
Args:
month: A value for month between 1-12 (Default: 1).
day: A value for day between 1-31 (Default: 1).
hour: A value for hour between 0-23 (Default: 0).
minute: A value for month between 0-59 (Default: 0).
leap_year: A boolean to indicate if datetime is for a leap year
(Default: False).
This file has been truncated. show original
-trevor
Hi,
Thanks, but you kind of linked the same link that I posted in the question…
What is missing from those code samples is the function .tm_yday
Hi, thanks!
In the end I solved it similarly with converting the DateTime object directly:
hoy = round(hoy + (i.minute/10) * .166667,5)
where ‘i’ is the DateTime.