benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 0892f8c9-464e-5b4a-b67e-1c1040fca6ab

Problem

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

complete prompt

import pytz
from dateutil import parser

def task_func(date_str, from_tz, to_tz):
    """
    Converts a date time from one timezone to another.

    Parameters:
    date_str (str): The date string in "yyyy-mm-dd hh:mm:ss" format.
    from_tz (str): The timezone of the given date string.
    to_tz (str): The timezone to which the date should be converted.

    Returns:
    str: The converted datetime string in "yyyy-mm-dd hh:mm:ss" format.

    Requirements:
    - pytz
    - dateutil.parser

    Example:
    >>> task_func('2022-03-01 12:00:00', 'UTC', 'America/New_York')
    '2022-03-01 07:00:00'
    """

instruct prompt

Converts a date time from one timezone to another.
The function should output with:
    str: The converted datetime string in "yyyy-mm-dd hh:mm:ss" format.
You should write self-contained code starting with:

Code

import pytz
from dateutil import parser
def task_func(date_str, from_tz, to_tz):

code prompt

Code

import pytz
from dateutil import parser
def task_func(date_str, 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