Create arrays of dates
Unlike bash, Murex also supports date ranges:
» a: [25-dec-2020..05-jan-2021]
» a: [..25-dec-2020]
» a: [25-dec-2020..]
Please refer to a (mkarray) for more detailed usage of mkarray.
a: [start..end] -> <stdout>
a: [start..end,start..end] -> <stdout>
a: [start..end][start..end] -> <stdout>
All usages also work with ja
and ta
as well, eg:
ja: [start..end] -> <stdout>
ta: data-type [start..end] -> <stdout>
You can also inline arrays with the %[]
syntax, eg:
%[start..end]
» a: [25-Dec-2020..01-Jan-2021]
25-Dec-2020
26-Dec-2020
27-Dec-2020
28-Dec-2020
29-Dec-2020
30-Dec-2020
31-Dec-2020
01-Jan-2021
» a: [31-Dec..25-Dec]
31-Dec
30-Dec
29-Dec
28-Dec
27-Dec
26-Dec
25-Dec
If the start value is missing (eg [..01-Jan-2020]
) then mkarray (a
et al) will start the range from the current date and count up or down to the end.
If the end value is missing (eg [01-Jan-2020..]
) then mkarray will start at the start value, as usual, and count up or down to the current date.
For example, if today was 25th December 2020:
» a: [23-December-2020..]
23-December-2020
24-December-2020
25-December-2020
» a: [..23-December-2020]
25-December-2020
24-December-2020
23-December-2020
This can lead so some fun like countdowns:
» out: "${a: [..01-January-2021] -> len -> =-1} days until the new year!"
7 days until the new year!
Date ranges are case aware. If the ranges are uppercase then the return will be uppercase. If the ranges are title case (capital first letter) then the return will be in title case.
» a: [01-jan..03-jan]
01-jan
02-jan
03-jan
» a: [01-Jan..03-Jan]
01-Jan
02-Jan
03-Jan
» a: [01-JAN..03-JAN]
01-JAN
02-JAN
03-JAN
Below is the source for the supported formatting options for date ranges:
package mkarray
var dateFormat = []string{
// dd mm yy
"02-Jan-06",
"02-January-06",
"02-Jan-2006",
"02-January-2006",
"02 Jan 06",
"02 January 06",
"02 Jan 2006",
"02 January 2006",
"02/Jan/06",
"02/January/06",
"02/Jan/2006",
"02/January/2006",
// mm dd yy
"Jan-02-06",
"January-02-06",
"Jan-02-2006",
"January-02-2006",
"Jan 02 06",
"January 02 06",
"Jan 02 2006",
"January 02 2006",
"Jan/02/06",
"January/02/06",
"Jan/02/2006",
"January/02/2006",
// dd mm
"02-Jan",
"02-January",
"02 Jan",
"02 January",
"02/Jan",
"02/January",
}
If you do need any other formatting options not supported there, you can use datetime
to convert the output of a
. eg:
» a: [01-Jan-2020..03-Jan-2020] -> foreach { -> datetime --in "{go}02-Jan-2006" --out "{py}%A, %d %B"; echo }
Wednesday, 01 January
Thursday, 02 January
Friday, 03 January
[[
(element): Outputs an element from a nested structure[
(index): Outputs an element from an array, map or table[
(range): Outputs a ranged subset of data from STDINa
(mkarray): A sophisticated yet simple way to build an array or listcount
: Count items in a map, list or arraydatetime
: A date and/or time conversion tool (like printf
but for date and time values)ja
(mkarray): A sophisticated yet simply way to build a JSON arraymtac
: Reverse the order of an arrayta
(mkarray): A sophisticated yet simple way to build an array of a user defined data-typeThis site's content is rebuilt automatically from murex's source code after each merge to the master
branch. Downloadable murex binaries are also built with the website.
Last built on Fri May 19 22:45:48 UTC 2023 against commit 54b5f6754b5f67b250bbf7353e83c42ed187802584c3ae3.
Current version is 4.1.6140 which has been verified against 14045 tests cases.