Skip to content
Snippets Groups Projects
Commit ab6bb39e authored by Mirar (Pontus Hagland)'s avatar Mirar (Pontus Hagland)
Browse files

changed the dwim of time formats slightly

Rev: lib/modules/Calendar.pmod/YMD.pmod:1.13
parent bd4660ad
No related branches found
No related tags found
No related merge requests found
...@@ -2350,7 +2350,7 @@ TimeRange parse(string fmt,string arg) ...@@ -2350,7 +2350,7 @@ TimeRange parse(string fmt,string arg)
string nfmt; string nfmt;
nfmt=replace(fmt," %","%*[ \t]%"); // whitespace -> whitespace nfmt=replace(fmt," %","%*[ \t]%"); // whitespace -> whitespace
#define ALNU "%[^ -,./:-?[-`{-]" #define ALNU "%[^- -,./:-?[-`{-]"
#define AMPM "%[ampAMP]" #define AMPM "%[ampAMP]"
#define NUME "%[0-9]" #define NUME "%[0-9]"
nfmt=replace(nfmt, nfmt=replace(nfmt,
...@@ -2582,8 +2582,8 @@ array dwim_day_strings= ...@@ -2582,8 +2582,8 @@ array dwim_day_strings=
"%y-%M-%D", "%y-%M-%D",
"-%y%*[ /]%D%*[ /]%M", "-%y%*[ /]%D%*[ /]%M",
"-%y%*[ /]%M%*[ /]%D", "-%y%*[ /]%M%*[ /]%D",
"%y%*[ /]%D%*[ /]%M",
"%y%*[ /]%M%*[ /]%D", "%y%*[ /]%M%*[ /]%D",
"%y%*[ /]%D%*[ /]%M",
"%D%*[- /]%M", "%D%*[- /]%M",
"%M%*[- /]%D", "%M%*[- /]%D",
"%e%*[- /wv]%W%*[ -/]%y", "%e%*[- /wv]%W%*[ -/]%y",
...@@ -2629,27 +2629,41 @@ TimeofDay dwim_time(string what) ...@@ -2629,27 +2629,41 @@ TimeofDay dwim_time(string what)
string a,h,m,s; string a,h,m,s;
TimeofDay t; TimeofDay t;
foreach ( ({ " %z","%z",""}), foreach ( dwim_day_strings +
string zone ) ({""}),
foreach ( ({ "%t", string dayformat )
foreach ( ({ "%t %z",
"T%t %z",
"T%t", "T%t",
"%h:%*[ :]%m%*[ :]%s %p %z",
"%h:%*[ :]%m%*[ :]%s %p", "%h:%*[ :]%m%*[ :]%s %p",
"%h:%*[ :]%m%*[ :]%s %z",
"%h:%*[ :]%m%*[ :]%s%z",
"%h:%*[ :]%m%*[ :]%s", "%h:%*[ :]%m%*[ :]%s",
"%h:%*[ :]%m %p %z",
"%h:%*[ :]%m %p", "%h:%*[ :]%m %p",
"%h:%*[ :]%m %z",
"%h:%*[ :]%m%z",
"%h:%*[ :]%m", "%h:%*[ :]%m",
"%h%*[ ]%p", "%h%*[ ]%p",
"%[a-zA-Z.] %h:%*[ :]%m%*[ :]%s %p %z",
"%[a-zA-Z.] %h:%*[ :]%m%*[ :]%s %p", "%[a-zA-Z.] %h:%*[ :]%m%*[ :]%s %p",
"%[a-zA-Z.] %h:%*[ :]%m%*[ :]%s %z",
"%[a-zA-Z.] %h:%*[ :]%m%*[ :]%s%z",
"%[a-zA-Z.] %h:%*[ :]%m%*[ :]%s", "%[a-zA-Z.] %h:%*[ :]%m%*[ :]%s",
"%[a-zA-Z.] %h:%*[ :]%m %p %z",
"%[a-zA-Z.] %h:%*[ :]%m %p", "%[a-zA-Z.] %h:%*[ :]%m %p",
"%[a-zA-Z.] %h:%*[ :]%m %z",
"%[a-zA-Z.] %h:%*[ :]%m%z",
"%[a-zA-Z.] %h:%*[ :]%m", "%[a-zA-Z.] %h:%*[ :]%m",
"%[a-zA-Z.] %h%*[ ]%p", }), "%[a-zA-Z.] %h%*[ ]%p", }),
string todformat ) string todformat )
foreach ( dwim_day_strings +
({""}),
string dayformat )
{ {
if ( (t=parse(dayformat+"%*[ ,]"+todformat+zone,what)) ) return t; // werror("try: %O\n %O\n",
if ( (t=parse(todformat+zone+"%*[ ,]"+dayformat,what)) ) return t; // dayformat+"%*[ ,]"+todformat,
// todformat+"%*[ ,]"+dayformat);
if ( (t=parse(dayformat+"%*[ ,]"+todformat,what)) ) return t;
if ( (t=parse(todformat+"%*[ ,]"+dayformat,what)) ) return t;
} }
error("Failed to dwim time from %O\n",what); error("Failed to dwim time from %O\n",what);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment