Code Monkey home page Code Monkey logo

Comments (1)

masukomi avatar masukomi commented on June 12, 2024

Just realized that a nice way to handle this is to

  1. limit choice to an even hour. E.g. 4 AM not 4:44 AM
  2. whenever doing calculations for reporting purposes just have them run within a time zone that corresponds to the requested hour.

That is to say, if i'm in Eastern Standard Time and I set my "end/start of day" to 4 am then behind the scenes, and only for the purposes of finding day/week/month boundaries, change my time zone from GMT -5 (EST) to GMT -9 (AKST). Midnight AKST is 4AM EST. Once we've done that we can leverage all of Raku's built in day/month functionality without doing any funky math & custom day boundary calculations everywhere.

a simple example: hey log 3 days

  1. read in config for start/end of day
  2. see that it's 4 hours off and add +4 to current time zone.
  3. calculate the start of the day 3 days ago.
  4. get that as an epoch time.
    (at this point we're done mucking with the fake time zone)
  5. query the db for entries from that time forward
  6. pass the results on for reporting
    user output works as it already does with the current time zone.

from hey_3.

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.