Coder Social home page Coder Social logo

eo-time's Introduction

EO principles respected here DevOps By Rultor.com We recommend IntelliJ IDEA

Hits-of-Code Lines of code License

EO objects for date/time manipulations.

To get current time:

QQ.dt.now > t

To make time from absolute value in nano-seconds after Epoch:

QQ.dt.time > t
  1656855443000000

To make short time interval:

QQ.dt.nanosecond.mul 10 > ten-ns
QQ.dt.microsecond.mul 50 > fifty-mcs
QQ.dt.millisecond.mul 100 > hundred-ms
QQ.dt.second.mul 3 > three-seconds
QQ.dt.minute.mul 4 > four-minutes
QQ.dt.hour.mul 5 > five-hours
QQ.dt.day > one-day
QQ.dt.week.mul 2 > two-weeks

To print it in ISO 8601 format using strftime:

QQ.io.stdout
  QQ.txt.sprintf
    "Current time is %s"
    QQ.dt.strftime
      "%Y-%m-%dT%H:%M:%S%z"
      t

To parse ISO 8601 back to time using strptime:

QQ.dt.strptime > t
  "%Y-%m-%dT%H:%M:%S%z"
  "2022-07-03T20:26:09+0300"

The object QQ.dt.time has the following attributes:

  • plus adds two times
  • minus subtracts
  • eq compares
  • gt is TRUE if greater than
  • gte if greater than or equal
  • lt if less than
  • lte if less than or equal

For example, to add five hours and thirty minutes to the current time and then compare it with the time of file creation:

QQ.io.stdout
  if.
    gt.
      plus.
        QQ.dt.now
        QQ.dt.hour.mul 5
        QQ.dt.minute.mul 30
      utime.
        QQ.fs.file
          "test.txt"
    "The file is too old"
    "The file is fresh"

There are two objects that are aware of calendar specifics and must be used on the left side of the equation in order to respect the calendar. The following code will move current time three months ahead:

plus
  QQ.dt.month.mul 3
  QQ.dt.now

How to Contribute

Fork repository, make changes, send us a pull request. We will review your changes and apply them to the master branch shortly, provided they don't violate our quality standards. To avoid frustration, before sending us your pull request please run full Maven build:

$ mvn clean install -Pqulice

You will need Maven 3.3+ and Java 8+.

eo-time's People

Contributors

yegor256 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.