Download the PHP package felixdorn/nest without Composer
On this page you can find all versions of the php package felixdorn/nest. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download felixdorn/nest
More information about felixdorn/nest
Files in felixdorn/nest
Package nest
Short Description Nest is a simple pseudo-programming language for defining repeatable and non-repeatable events in time.
License MIT
Informations about the package nest
Nest
Nest is a simple pseudo-programming language for defining repeatable and non-repeatable events in time.
Here are a couple examples of the syntax:
Nest outputs a list of time periods.
Here's an example output for once 1/1/2021 from 15:00 to 16:00
:
Features
- Natural syntax
- Error reporting
- Fast
Already know this stuff? Jump to the API documentation
Reproducibility
The same code could lead to a completely different output based on the current time.
Therefore, when storing Nest code, you should also store the current time if reproducibility is an issue for you (it probably is).
Keywords
Once
Once indicates that an event is repeated once at a given date.
Implicit once
You may omit the once keyword if you write it at the start of the program.
15/04/2005
processed as once 2005-04-15
at 6 15/04/2005
throws Syntax error, unexpected 15/04/2005
Every
Every indicates that an event is repeated it takes as a parameter one or many weekdays.
See how lists work here.
You may use the shorthand everyday
that compiles to every day of the week
You may also use the shorthand weekend
that compiles to saturday and sunday
For
For indicates how long an event lasts.
Here's a guide on How you can quantify time in Nest
Here's a list of all the time measurement units you may use:
- minute
- hour
- day
- week
You may pluralize them to keep the sentence grammatically correct but the compiler won't pick up on it if you don't.
Shorthands such as 1h
(1 hour) are also allowed.
Here's a list of all available shorthands:
- m: minute
- h: hour
- d: day
- w: week
- min: minute
In
In sets the date of a non-repeatable event relatively to the current date.
Refer to the for keyword for a guide on time measurement units and how to quantify time.
Between
Between constrains the event between two dates.
If you wish to constrain an event between a time range, use from.
From ... to ...
From constrains the event between a time range.
Until
Until is a shorthand for the between keyword.
The start date is the current time.
At
At defines at which time an event starts. It is often used in combination with for
that sets the duration of the
event.
Lists
A list contains one or many literals such as monday
or 1:00
and these are separated with commas or the word and
.
Quantifying Time
You can use any number from one
to a sixty
in literal form.
You can use any non-negative integer such as 1
or 42
.
To represent one unit of time, you may use a simpler form:
The compiler doesn't make a difference if you write
a
oran
sofor a hour
still represents1 hour
even though it is grammatically incorrect.
API
Installation
If you don't have composer, you can download it here.
Usage
If your event does not have fixed boundaries set using between ... and ...
or until ...
, it repeats indefinitely.
Therefore, you need to set manual boundaries at compile-time hence the second CarbonPeriod
parameter. You can omit it
if you know that your event has fixed boundaries.