benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 6d02fc86-305f-50ff-904e-8db06e07005c

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import pytz
from dateutil.parser import parse

# Constants
TIME_FORMAT = "%d/%m/%y %H:%M:%S.%f"


def task_func(time_string, from_tz, to_tz):
    """
    Converts a time string from one timezone to another, considering various cases such as daylight saving time.

    Parameters:
    - time_string (str): A time string in the format 'dd/mm/yy HH:MM:SS.fff'. This string should represent a valid date and time.
    - from_tz (str): The timezone of the given time string. The timezone should be a valid IANA timezone name (e.g., 'UTC', 'America/New_York').
    - to_tz (str): The target timezone to which the time string should be converted. This should also be a valid IANA timezone name (e.g., 'Asia/Tokyo').

    Returns:
    - str: The converted time string in the format 'dd/mm/yy HH:MM:SS.fff'. The conversion takes into account any differences in daylight saving rules between the source and target timezones.

    Requirements:
    - pytz
    - dateutil

    Example:
    >>> task_func('30/03/09 16:31:32.123', 'UTC', 'America/New_York')
    '30/03/09 12:31:32.123000'

    Note: The example assumes no daylight saving time shift between the given timezones at the specified date and time.
    """

instruct prompt

Converts a time string from one timezone to another, considering various cases such as daylight saving time.
Note that: The example assumes no daylight saving time shift between the given timezones at the specified date and time.
The function should output with:
    str: The converted time string in the format 'dd/mm/yy HH:MM:SS.fff'. The conversion takes into account any differences in daylight saving rules between the source and target timezones.
You should write self-contained code starting with:

Code

import pytz
from dateutil.parser import parse
# Constants
TIME_FORMAT = "%d/%m/%y %H:%M:%S.%f"
def task_func(time_string, from_tz, to_tz):

code prompt

Code

import pytz
from dateutil.parser import parse
# Constants
TIME_FORMAT = "%d/%m/%y %H:%M:%S.%f"
def task_func(time_string, from_tz, to_tz):

entry point

task_func

libs

  • pytz
  • dateutil

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import