Module time

Module time 

Source
Expand description

Time utilities for CCXT

This module provides time-related utility functions for timestamp conversion, date parsing, and formatting. All timestamps are in milliseconds since Unix epoch unless otherwise specified.

§Key Features

  • Millisecond/second/microsecond timestamp generation
  • ISO 8601 date parsing and formatting
  • Multiple date format support
  • UTC timezone handling

§Example

use ccxt_core::time::{milliseconds, iso8601, parse_date};

// Get current timestamp in milliseconds
let now = milliseconds();

// Convert timestamp to ISO 8601 string
let iso_str = iso8601(now).unwrap();

// Parse ISO 8601 string back to timestamp
let parsed = parse_date(&iso_str).unwrap();
assert_eq!(now, parsed);

Functions§

iso8601
Converts a timestamp in milliseconds to an ISO 8601 formatted string
microseconds
Returns the current time in microseconds since the Unix epoch
milliseconds
Returns the current time in milliseconds since the Unix epoch
parse_date
Parses a date string and returns the timestamp in milliseconds since Unix epoch
parse_iso8601
Parses an ISO 8601 date string and returns the timestamp in milliseconds
seconds
Returns the current time in seconds since the Unix epoch
ymd
Alias for yyyymmdd function
ymdhms
Formats a timestamp as “yyyy-MM-dd HH:mm:ss”
yymmdd
Formats a timestamp as “yy-MM-dd”
yyyymmdd
Formats a timestamp as “yyyy-MM-dd”