Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

community: timezone added as zoneinfo object in 365 toolkits #23581

Closed

Conversation

abhishekshingadiya
Copy link

timezone added as zoneinfo
timezone added as zoneinfo
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 27, 2024
Copy link

vercel bot commented Jun 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain 🛑 Canceled (Inspect) Nov 4, 2024 8:02pm

@dosubot dosubot bot added community Related to langchain-community 🤖:improvement Medium size change to existing code to handle new use-cases labels Jun 27, 2024
@abhishekshingadiya
Copy link
Author

Other solution with pytz

import pytz
from datetime import datetime as dt, timedelta


def get_timezones_by_offset(sign, offset_hours_str, offset_minutes_str):
    # Convert inputs to integers after stripping any leading zeros
    offset_hours = int(offset_hours_str.lstrip('0'))
    if offset_minutes_str != '00':
        offset_minutes = int(offset_minutes_str.lstrip('0') or '0')
    else:
        offset_minutes = int(offset_minutes_str)
    target_offset = timedelta(hours=offset_hours, minutes=offset_minutes)
    if sign == '-':
        target_offset = -timedelta(hours=offset_hours, minutes=offset_minutes)

    matching_timezones = []

    for tz_name in pytz.all_timezones:
        tz = pytz.timezone(tz_name)
        now = dt.now(tz)
        if now.utcoffset() == target_offset:
            matching_timezones.append(tz_name)

    if not matching_timezones:
        return "UTC"
    else:
        return matching_timezones[0]


print(get_timezones_by_offset('+','05', '30'))
print(get_timezones_by_offset('-', '03', '30'))

Update event.start and event.end

event.start = dt.strptime(start_datetime, UTC_FORMAT).replace(tzinfo=ZoneInfo(
    get_timezones_by_offset(start_datetime[-6], start_datetime[-5:-3], start_datetime[-2:])))
event.end = dt.strptime(end_datetime, UTC_FORMAT).replace(tzinfo=ZoneInfo(
    get_timezones_by_offset(start_datetime[-6], start_datetime[-5:-3], start_datetime[-2:])))
        

@langcarl
Copy link

langcarl bot commented Nov 4, 2024

Thank you for the PR. This PR is marked Needs Support and has not yet received the 5 upvotes required by maintainers for review. It has been open for at least 25 days. Per the LangChain review process, this PR will be closed in 5 days if it does not reach the required threshold.

The Needs Support status is intended to prioritize review time on features that have demonstrated community support. If you feel this status was assigned in error or need more time to gather the required upvotes, please ping @ccurme and @efriis.

@langcarl langcarl bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Related to langchain-community 🤖:improvement Medium size change to existing code to handle new use-cases size:M This PR changes 30-99 lines, ignoring generated files. stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants