Code Monkey home page Code Monkey logo

Comments (1)

joshstrange avatar joshstrange commented on June 18, 2024

It looks like this should be as simple as:

120 - (Math.round((new GregorianCalendar()).getTimeInMillis() / 1000) % 120)

Where 120 is the second you make it valid:

.setTimeStepSizeInMillis(TimeUnit.SECONDS.toMillis(120))

Of course your window size will probably make it valid for LONGER but for the purposes of UI this gives me an accurate countdown. In the end since this is for a web app I'll probably just do the calculation in javascript on the front end:

console.log(120 - Math.round(new Date() / 1000) % 120)

Yes, the web front end is acting like a TOTP generator for another device, I know it sounds weird but trust me, it's what I want for the project I'm working on.

from googleauth.

Related Issues (20)

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.