cubewise-code / tm1py

TM1py is a Python package that wraps the TM1 REST API in a simple to use library.
http://tm1py.readthedocs.io/en/latest/
MIT License
189 stars 109 forks source link

MessageLogService missing utc_localize_time static method #1051

Closed adscheevel closed 9 months ago

adscheevel commented 9 months ago

Describe the bug With migration of message log methods out of Server Service to new MessageLog Service, the dependent utc_localize_time method was left in Server Service when it should have been migrated to new MessageLog Service

To Reproduce

from TM1py import TM1Service
from datetime import date, datetime

tm1params = {...}

with TM1Service(**tm1params) as tm1:
    date_min = datetime.combine(date.today(), datetime.min.time())
    tm1.message_logs.get_entries(since=date_min, top=1)

Expected behavior return top message with since filter of midnight of current day

Version TM1py 2.0 TM1 Server Version: 11.8.01

Additional context Will submit PR shortly with fix. This can be bypassed by including timezone info in the datetime object as in example below (using UTC, but user should use whatever timezone their TM1 server is localized to.

from TM1py import TM1Service
from datetime import date, datetime
import pytz

tm1params = {...}

with TM1Service(**tm1params) as tm1:
    date_min = datetime.combine(date.today(), datetime.min.time(), pytz.UTC)
    tm1.message_logs.get_entries(since=date_min, top=1)

example specifying a timezone e.g. US/Eastern

from TM1py import TM1Service
from datetime import date, datetime
import pytz

tm1params = {...}

with TM1Service(**tm1params) as tm1:
    date_min = datetime.combine(date.today(), datetime.min.time(), pytz.timezone('US/Eastern'))
    tm1.message_logs.get_entries(since=date_min, top=1)
adscheevel commented 9 months ago

Closing as the fix will be in 2.0.2