Skip to content

Rust Implementation #1

@benkaiser

Description

@benkaiser

Hey @telmich , I was just mucking around with GPT-3 and created a rust implementation of SUT:

// Import the DateTime crate
use chrono::{DateTime, Local, Timelike};

fn main() {
    // Get the current time
    let now: DateTime<Local> = Local::now();

    // Calculate the total number of seconds in the day
    let total_seconds: u32 = (((now.hour() * 3600) + (now.minute() * 60) + (now.second())) as f32 * (100000.0 / 86400.0)) as u32;

    // Convert the total number of seconds to Simple Universal Time
    let sut_hours: u32 = total_seconds / 10000;
    let sut_minutes: u32 = (total_seconds / 100) % 100;
    let sut_seconds: u32 = total_seconds % 100;

    // Output the Simple Universal Time
    println!("SUT {}:{}:{}", sut_hours, sut_minutes, sut_seconds);
}

Can't believe it's 10 years since I wrote the C implementation!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions