ocaml-community / calendar Goto Github PK
View Code? Open in Web Editor NEWOCaml library for handling dates and times.
License: Other
OCaml library for handling dates and times.
License: Other
The current behavior is this:
utop # Date.make 2017 1 32 |> Printer.Date.to_string;;
- : string = "2017-02-01"
This probably depends on #6
Currently the default opam installation doesn't generate any documentation via odoc
The old docs used to have useful information on the formats: https://web.archive.org/web/20160415075101/http://calendar.forge.ocamlcore.org/doc/Printer.html
It's no longer the case. The original documentation links don't work anymore, and the new docs leave the user to guess what the available specifiers are.
I can help fix it, but I need to know where you think this info should be in the docs.
There is currently Calendar
, Calendar.Precise
, FCalendar
and FCalendar.Precise
, all with various float/int combination. The tradeoffs are absolutely not explained in the documentation, and I'm quite sure they don't apply anymore, in these times of ubiquitous 64bit systems. We should be able to clean all that up.
**Originally reported here by Jérôme Vouillon @vouillon **
New Zealand is at UTC+12:00, which is not accepted by Calendar. Indeed, we have this code in time_Zone.ml:
let out_of_bounds x = x < - 12 || x > 11
This is affected by commit but needs to be verified by a test and maybe we need to come up with new, reasonable limitations
PR #6 created a src/dune
which calls date(1)
, see commit 486d180
Storing a random date in binaries was never a good idea, in any project, at any time.
Debian sells a feature called "reproducible build", openSUSE/build-compare just wants to avoid needless republish to reduce load on mirrors.
Please, remove the version.ml:date API. It can not possibly serve any useful purpose...
Not sure that #15 is still relevant. Using currently release odoc
i'm able to generate documentation using dune build @doc
. It might be nice to have that output hosted on the gh-pages branch so it can be viewed online.
@pmetzger @Drup - I added the Travis CI status banner but I don't seem to have any actual control over Travis CI itself, as I am not listed as ocaml-community
member. Because of this in the Travis CI admin panel I don't see the calendar
project.
Please have a look if you can run a new CI build and if the build will light up green.
utop [21]: Date.is_leap_year 2000;;
- : bool = true
utop [22]: Date.is_leap_day (Date.make 2000 2 29);;
- : bool = false
Line 212 in a447a88
This seems to just be defined incorrectly.
there are some global mutations in the lib (e.g. Time_zone.change
) which make reasoning about the library complicated.
I think it'd be nice to instead have a ?tz:Time_zone.t
argument in functions that make use of the global state, to overload it.
short_name_of_day
and short_name_of_month
use:
String.sub s 0 3
This will only work with languages using ASCII chars only, but it doesn't work with UTF-8 characters.
In addition to the functions refs month_name
and day_name
we should also create month_short_name
and day_short_name
.
Originally reported here by Stephen Dolan
I expected that if I use CalendarLib.Calendar.Precise.precise_sub to compute the difference between two dates, then I could add this difference to the earlier and get the later.
However, if I attempt this on [2025-03-31 17:53:04; 2026-07-19 12:15:23], then the result of add is 2026-07-20 12:15:23, not 2026-07-19 12:15:23.
I note the name bs-calendar
. Can this be used in the browser with ReasonML/Bucklescript/ReScript?
Thank you!
I have some code that needs to output a large number of dates to a clean format, but I noticed that this was quite slow.
With this benchmark:
open Core;
open Core_bench.Std;
let main = () => {
let date = CalendarLib.Calendar.from_unixfloat(1000329.);
Command.run(
Bench.make_command([
Bench.Test.create(~name="format", () => ignore(CalendarLib.Printer.Calendar.sprint("%iT%T%z", date))),
]),
);
};
let () = main();
I get this output:
┌────────┬──────────┬─────────┬──────────┬──────────┬────────────┐
│ Name │ Time/Run │ mWd/Run │ mjWd/Run │ Prom/Run │ Percentage │
├────────┼──────────┼─────────┼──────────┼──────────┼────────────┤
│ format │ 2.95us │ 721.26w │ 1.07w │ 1.07w │ 100.00% │
└────────┴──────────┴─────────┴──────────┴──────────┴────────────┘
I'm not sure if you are considering this slow, but to me it was totally unexpected that something like this would take up a large amount of time in my code (after benchmarking almost 50% of my time goes to formatting the date).
When using Calendar_Precise it's even a bit slower (about 0,5 microseconds added)
Am I doing something wrong here? Or is this something that is just slow?
I haven't been able to spend a lot of time with calendar (and OCaml in general) for the past months.
My initial plan was to stabilise this branch and then merge it in to master and do a 3.0 release, which would be considered backwards incompatible.
What I'm lacking right at the moment is knowledge on how to do Opam releases.
Please, anyone interested, comment on what you prefer with regards of branches and releases.
Probably @pmetzger was right after all - continuing in master might be a good idea.
I may have missed it, but I couldn't find this new version of Calendar on opam. Is there any plan to release it in the foreseeable future? I'm particularly interested in the switch from Str to Re...
at a glance it seems to use a custom test module, we could use alcotest+qcheck or something like that?
Originally reported here by Petter Urkedal
The calendar library seems to apply DST of the current date rather than the date to be converted. From a locale time zone with DST, the following should show the problem:
Printer.Calendar.to_string (on (fun () -> Calendar.make 2015 1 1 10 00 00) UTC ());;
- : bytes = "2015-01-01 12:00:00"
Printer.Calendar.to_string (on (fun () -> Calendar.make 2015 7 1 10 00 00) UTC ());;
- : bytes = "2015-07-01 12:00:00"
As I'm in a CET with DST time zone I would expect the first to return 11:00:00.
Calendar version 2.03.2.
Hi, currently no release of calendar
work on OCaml 5.0 (see ocaml/opam-repository#22208) but master
compiles just fine.
Any chance someone could do a release of calendar
to add support for OCaml 5.0 ?
Right now, I believe the CI is failing because of the lack of an OPAM file. One should be added. It won't take much effort once the dune migration @c-cube is doing is done.
if you want help with this, I can try to help.
The DatePrinter.from_fsrting
function appears to work correctly with all possible formats.
utop # CalendarLib.Printer.DatePrinter.from_fstring "%Y-%m-%d %H:%M%z" "1970-01-01 00:00+0000" |> CalendarLib.Printer.DatePrinter.sprint "%d/%m/%Y" ;;
- : string = "01/01/1970"
If you want to handle both date and time, however... The CalendarPrinter.from_fstring
function fails with a generic exception for most formats.
utop # CalendarLib.Printer.CalendarPrinter.from_fstring "%Y-%m-%d %H:%M%z" "1970-01-01 00:00+0000" |> CalendarLib.Printer.CalendarPrinter.sprint "%d/%m/%Y" ;;
Exception: Invalid_argument "Cannot create the calendar".
It only seems to works for shortcut format specifiers that include both date and time, like %c
.
utop # CalendarLib.Printer.CalendarPrinter.from_fstring "%c" "Thu Sep 18 14:10:51 2003" |> CalendarLib.Printer.CalendarPrinter.sprint "%d/%m/%Y" ;;
- : string = "18/09/2003"
Hi,
I just tried to download & install this library, but the first step of the documentation is already not direct:
$ ./configure
bash: ./configure: Aucun fichier ou dossier de ce type
Thanks in advance!
(I could probably find on my own how to proceed, but the documentation should be improved, if possible!)
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.