Giter Club home page Giter Club logo

Comments (3)

dbuezas avatar dbuezas commented on June 5, 2024

Uhm. This is a bit trickier that what I thought: the duration specified is internally converted to milliseconds. Later in the code, I don't really know if you wrote 1w or 7d or 168h.
This means that it is not quite clear where to reset. For example

  • every 30 days from the beginning of the year vs every 1st day of the month
  • every 7 days starting the beginning of the month vs the a Monday vs beginning of year
  • ...

I think the most intuitive behaviour is to use a specific parsing algorithm for this use case where the unit is kept, decimals are not allowed(i.e you can't do 1.5 weeks)

  • if the unit is years -> start on 1st of Jan
  • if months -> start on 1st of Jan and add calendar months
  • If weeks -> start on a Monday and add whole weeks
  • if days, hours, mins, secs, ms -> start at midnight

Do you see any corner case with this approach?

from lovelace-plotly-graph-card.

JvdMaat avatar JvdMaat commented on June 5, 2024

I would agree no decimals, if you reset every 1.5 days, what is your start day? Which days get cut in half? Too much ambiguity.

Every month resets on the 1st of each month (is that possible? I know in the yaml if you specify 1M, it really translates to 30 days, not exactly a month depending on which month we're in. If you start it on Jan 1st, it'll be off all year since Jan is 31 days. And after 12 months (365 days) you're off by 5 days.)

Every week restarts on each Monday in my world. But I know there are a lot of Sunday fanatics as well (I don't think HA has a "first day of week" setting. At least I couldn't find one just now. You may be able to pull that out of the OS? (Though not sure if that's exposed)). So the every week one could be an issue here and there depending on localization.

from lovelace-plotly-graph-card.

dbuezas avatar dbuezas commented on June 5, 2024

HA does allow changing the first day of the week. To do it, click on your name on the left side bar. This card uses that to configure what "current_week" means :)

Resetting on the 1st is indeed possible, I'll need to "remember" the unit used and work with the actual calendar dates instead of bare milliseconds.

I think it will work

from lovelace-plotly-graph-card.

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.