Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Infiniflow Ragflow Time Utils

From Leeroopedia
Knowledge Sources
Domains Utilities, Data_Processing
Last Updated 2026-02-12 06:00 GMT

Overview

Concrete tool providing timestamp and datetime conversion utilities for the RAGFlow application.

Description

The time_utils module provides functions for getting the current Unix timestamp in milliseconds, converting between timestamps and formatted date strings, normalizing datetime objects, calculating time deltas, and converting ISO 8601 timestamps to a standard display format.

Usage

Import these utilities when working with task timestamps, document creation dates, log entries, or any time-sensitive data that needs format conversion between Unix timestamps and human-readable strings.

Code Reference

Source Location

Signature

def current_timestamp() -> int:
    """Get current Unix timestamp in milliseconds."""

def timestamp_to_date(timestamp: int, format_string: str = ...) -> str:
    """Convert Unix timestamp to formatted date string."""

def date_string_to_timestamp(time_str: str, format_string: str = ...) -> int:
    """Convert date string to Unix timestamp in milliseconds."""

def datetime_format(date_time) -> datetime:
    """Normalize datetime by removing microseconds."""

def delta_seconds(date_string: str) -> float:
    """Calculate seconds from given date to now."""

def format_iso_8601_to_ymd_hms(time_str: str) -> str:
    """Convert ISO 8601 to 'YYYY-MM-DD HH:MM:SS' format."""

Import

from common.time_utils import current_timestamp, timestamp_to_date, datetime_format

I/O Contract

Inputs

Name Type Required Description
timestamp int Yes Unix timestamp in milliseconds
time_str str Yes Formatted date string
format_string str No strftime format pattern

Outputs

Name Type Description
current_timestamp() returns int Current time as Unix ms timestamp
timestamp_to_date() returns str Formatted date string
delta_seconds() returns float Seconds elapsed since given date

Usage Examples

from common.time_utils import current_timestamp, timestamp_to_date

ts = current_timestamp()  # 1707696000000
date = timestamp_to_date(ts)  # "2024-02-12 00:00:00"

from common.time_utils import format_iso_8601_to_ymd_hms
formatted = format_iso_8601_to_ymd_hms("2024-02-12T00:00:00Z")  # "2024-02-12 00:00:00"

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment