Code Monkey home page Code Monkey logo

clock's Introduction

Rust Clock Utility

A simple command-line utility to get and set the system time. The program is written in Rust and uses the chrono, clap, byteorder, and platform-specific libraries to interact with the system time.

Features

  • Get the current system time
  • Set the system time
  • Check the system time against NTP servers

Usage

# clock --help
Usage: clock [OPTIONS] [ACTION] [DATETIME]

Arguments:
  [ACTION]    Action to perform [default: get] [possible values: get, set, check]
  [DATETIME]  When <action> is 'set', apply <datetime>. Otherwise, ignore.

Options:
  -s, --std <STD>  Time standard to use [default: rfc3339] [possible values: rfc2822, rfc3339, timestamp]
  -h, --help       Print help
  -V, --version    Print version

Dependencies

  • chrono for date and time manipulation
  • clap for command-line argument parsing
  • byteorder for byte order manipulation
  • Platform-specific libraries (libc for Unix, kernel32 and winapi for Windows) for system time interaction

Example

Get the current time in RFC3339 format:

bash

clock

Set the system time using an RFC3339 formatted date-time string:

rust -a set -s rfc3339 "2023-04-03T10:30:00Z"

Disclaimer

This package is for educational purposes only and is the result of following the Rust in Action book by Tim McNamara. It is not intended for production use or as a complete, robust solution for managing system time. Users should exercise caution and understand the implications of modifying system time before using this code. The author of this package and the creators of the Rust in Action book shall not be held responsible for any unintended consequences or damages resulting from the use of this package.

clock's People

Contributors

anis-dr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.