aredington / monotony Goto Github PK
View Code? Open in Web Editor NEWA scheduling library for humans.
License: MIT License
A scheduling library for humans.
License: MIT License
period-named?
sounds like it compares against a string, but it actually compares against a key. Moreover, if you pass in a string, you get a NullPointerException.
The concept of a "named" period is a bit deceiving, because all you do is compare the value of the field at the start and end times. For example:
(m/period-named? conf (first (m/periods conf :week)) :august)
;; true
I'm wondering if it's better to to offer something like:
(m/start-day-of-week conf period)
;; (.get (m/calendar conf (t/start period)) Calendar/DAY_OF_WEEK)
(= Calendar/SUNDAY (m/start-day-of-week conf period))
;; true
The thought would be to open up utility functions to go from periods to the calendar fields for the start and end instants.
What do you think?
The periods returned by monotony do not accurately reflect the TimeZone data of the config. Per #5, a config for New York (U.S. Eastern Time) returns instants that are in UTC. It should be returning instants that reflect the TimeZone data of the config.
Hello Alex,
Have you considered inclusive and exclusive boundaries to capture the time outside the 1-second quantization?
An example is the PostgreSQL Temporal Extension period type:
period
--------------------------------------------------
[2011-01-01 00:00:00-08, 2012-01-01 00:00:00-08)
This particular text representation is not appropriate for lisp, but the functionality seems like a good fit for monotony.
http://temporal.projects.postgresql.org/reference.html
Paraphrasing:
"The period text representation is one of the following forms:
[ timestamptz, timestamptz )
( timestamptz, timestamptz ]
[ timestamptz, timestamptz ]
"Where timestamptz is a valid representation of a timestamptz. The choice of brackets represents the inclusiveness of the interval. A square bracket makes that side inclusive, and a peren makes that side exclusive.
Thanks,
Jeff
Hi! Just watched your "lightning talk" from 2011 and my curiosity was piqued to see if your library does better than Rails' Active Support when it comes to doing arithmetic on dates...
(import 'java.util.Calendar 'java.util.TimeZone)
(def tz (TimeZone/getTimeZone "America/New_York"))
(def cal (m/local-cal))
(.setTimeZone cal tz)
(.set cal Calendar/MONTH 10)
(.set cal Calendar/DATE 1)
; DST ends on Nov 3 in EST...
(def config {:calendar (fn [] cal) :seed (fn [] (.getTimeInMillis cal))})
; get the period spanning the DST change...
(last (take 3 (m/periods conf :day)))
=> [#inst "2013-11-03T04:00:00.000-00:00" #inst "2013-11-04T04:59:59.999-00:00"]
You can see here that currently, Monotony incorrectly defines a "day" as a fixed 24 hours. Depending on where you are, a "day" can be 23 or 25 hours when going in or out of DST.
The way Rails handles all such cases really bugs me: when you are adding time intervals, it converts the interval down to an offset in seconds, then blindly adds that number of seconds without considering leap years, differences in the length of the different months, etc. Monotony has the right idea when it comes to years and months; it would be nice to handle hours/days correctly as well.
As an aside, thanks for making this library available!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.