benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf b3a525b6-067b-5ad5-88e6-72b79cb9d85f

Problem

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

complete prompt

from datetime import datetime
import pytz

# Constants
DATE_FORMAT = '%Y-%m-%d %H:%M:%S'


def task_func(unix_timestamp, target_timezone):
    """
    Converts a Unix timestamp to a formatted date and time string in a specified timezone.

    Parameters:
    unix_timestamp (int): The Unix timestamp representing the number of seconds since the Unix Epoch (January 1, 1970, 00:00:00 UTC).
    target_timezone (str): The string identifier of the target timezone (e.g., 'America/New_York').

    Returns:
    str: A string representing the date and time in the target timezone, formatted as '%Y-%m-%d %H:%M:%S'.

    Requirements:
    - datetime.datetime
    - pytz

    Example:
    >>> unix_timestamp = 1609459200
    >>> target_timezone = 'America/New_York'
    >>> task_func(unix_timestamp, target_timezone)
    '2020-12-31 19:00:00'
    """

instruct prompt

Converts a Unix timestamp to a formatted date and time string in a specified timezone.
The function should output with:
    str: A string representing the date and time in the target timezone, formatted as '%Y-%m-%d %H:%M:%S'.
You should write self-contained code starting with:

Code

from datetime import datetime
import pytz
# Constants
DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
def task_func(unix_timestamp, target_timezone):

code prompt

Code

from datetime import datetime
import pytz
# Constants
DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
def task_func(unix_timestamp, target_timezone):

entry point

task_func

libs

  • pytz
  • datetime

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