MCPcopy Create free account
hub / github.com/FinancialComputingUCL/LOBFrame / get_datetime_from_seconds

Function get_datetime_from_seconds

data_processing/data_process.py:449–467  ·  view source on GitHub ↗
(seconds_after_midnight, date_str)

Source from the content-addressed store, hash-verified

447
448
449def get_datetime_from_seconds(seconds_after_midnight, date_str):
450 # Convert the date_str to a datetime.date object.
451 dt_date = datetime.strptime(date_str, "%Y-%m-%d").date()
452
453 # Calculate the time component from seconds_after_midnight.
454 hours = int(seconds_after_midnight // 3600)
455 minutes = int((seconds_after_midnight % 3600) // 60)
456 seconds = int(seconds_after_midnight % 60)
457 microseconds = int(
458 (seconds_after_midnight % 1) * 1e6
459 ) # Convert decimal part to microseconds.
460
461 # Create a datetime.time object for the time component.
462 dt_time = time(hour=hours, minute=minutes, second=seconds, microsecond=microseconds)
463
464 # Combine the date and time to create the datetime.datetime object.
465 dt_datetime = datetime.combine(dt_date, dt_time)
466
467 return dt_datetime

Callers 1

process_dataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected