Ftime

Testing the MarkupExpression ftime

Testing the MarkupExpression ftime

Today is 2022-08-18 Thu in PmWikiland where its is 22:12:47

 {(ftime %F -7days)}
 {(ftime %F when="2007-08-14 -1days")}
 {(ftime %F when="2007-08-14 -1 days")}
 {(ftime %F when="2007-08-14 -1 day")}
 {(ftime %F "2007-04-11 -4 days")}

 {(ftime %F when="2007-01-24 +1 day")}
 {(ftime %F when="2007-01-24 +1day")}
 {(ftime %F "+1 day")} ?today +1 use quotes
 {(ftime %F +1day)} ?today +1
 2022-08-11
 2007-08-13
 2007-08-13
 2007-08-13
 2007-04-07

 2007-01-25
 2007-01-25
 2022-08-19 ?today +1 use quotes
 2022-08-19 ?today +1
 {(ftime when=" ")}
 {(ftime %s)}
 {(ftime %s " ")}
 {(ftime %s when="")}
 {(ftime fmt=%F when="2007-08-14 -1days")}
 December 31, 1969, at 11:59 PM
 1660860767
 -1
 -1
 2007-08-13
 {(ftime News-20070501)}
 May 01, 2007, at 12:00 AM
 {(ftime MarchingOrders2007)}
 August 18, 2022, at 10:12 PM
 {(ftime 1177600111)}
 August 18, 2022, at 10:12 PM
 {(ftime %s)}
 1660860767
 {(ftime @1177600111)}
 April 26, 2007, at 03:08 PM
 {(ftime fmt="%b %#d %Y" when="second mon of Jan")}
 {(ftime fmt="%b %#d %Y" when="second tue of Feb")}
 {(ftime fmt="%b %#d %Y" when="second wed of Mar")}
 {(ftime fmt="%b %e %Y" when="second thu of Apr")}
 {(ftime fmt="%b %e %Y" when="second fri of May")}
 {(ftime fmt="%b %e %Y" when="second sat of Jun")}
 {(ftime fmt="%b %e %Y" when="third  sun of Jul")}
 {(ftime fmt="%b %e %Y" when="fourth mon of Aug")}
 {(ftime fmt="%b %e %Y" when="first  tue of Sep")}
 {(ftime fmt="%b %e %Y" when="second wed of Oct")}
 {(ftime fmt="%b %e %Y" when="third  thu of Nov")}
 {(ftime fmt="%b %e %Y" when="first  wed of Dec")}
----
 {(ftime fmt="%b %e %Y" when="second Monday of January")}
 {(ftime fmt="%b %e %Y" when="second Tuesday of February")}
...
 {(ftime fmt="%b %e %Y" when="first Wednesday of December")}
 Jan 10 2022
 Feb 08 2022
 Mar 09 2022
 Apr 14 2022
 May 13 2022
 Jun 11 2022
 Jul 17 2022
 Aug 22 2022
 Sep  6 2022
 Oct 12 2022
 Nov 17 2022
 Dec  7 2022

 Jan 10 2022
 Feb  8 2022

...

 Dec  7 2022

All these work on my own server, with or without the changes in DRange() for 2.2.69. --Petko October 19, 2014, at 06:12 AM

Testing relative GNU date input formats

Today is 2022-08-18 Thu

? marks an unsatisfactory result
 {(ftime "%Y %b %d %a" "1 mon")}
 {(ftime "%Y %b %d %a" "2 tue")}
 {(ftime "%Y %b %d %a" "3 wed")}
 {(ftime "%Y %b %d %a" "4 thu")} ?

 {(ftime "%Y %b %d %a" "1 sat")}
 {(ftime "%Y %b %d %a" "2 sat")}
 {(ftime "%Y %b %d %a" "3 sat")}
 {(ftime "%Y %b %d %a" "4 sat")} 

 {(ftime "%Y %b %d %a" "tuesday")}
 {(ftime "%Y %b %d %a" "last tue")}
 {(ftime "%Y %b %d %a" "this tue")}
 {(ftime "%Y %b %d %a" "next tue")} ?
 {(ftime "%Y %b %d %a" "thursday")}

 {(ftime "%Y %b %d %a" "last week")}
 {(ftime "%Y %b %d %a" "this week")}
 {(ftime "%Y %b %d %a" "next week")}
 2022 Aug 22 Mon
 2022 Aug 30 Tue
 2022 Sep 07 Wed
 2022 Sep 08 Thu ?

 2022 Aug 20 Sat
 2022 Aug 27 Sat
 2022 Sep 03 Sat
 2022 Sep 10 Sat 

 2022 Aug 23 Tue
 2022 Aug 16 Tue
 2022 Aug 23 Tue
 2022 Aug 23 Tue ?
 2022 Aug 18 Thu

 2022 Aug 08 Mon
 2022 Aug 15 Mon
 2022 Aug 22 Mon

All the above are correct; "4 thu" means "Thursday the fourth week", knowing that "next Thursday" is "this Thursday" or "Thursday the first week". --Petko

 {(ftime "%Y %b %d %a" "last month")} ?
 {(ftime "%Y %b %d %a" "this month")}
 {(ftime "%Y %b %d %a" "next month")}

 {(ftime "%Y %b %d %a" "June")} ?
 {(ftime "%Y %b %d %a" "last June")} ?
 {(ftime "%Y %b %d %a" "this June")} ?
 {(ftime "%Y %b %d %a" "next June")} ?
 {(ftime "%Y %b %d %a" "last Aug")} ?
 {(ftime "%Y %b %d %a" "this Aug")} ?
 {(ftime "%Y %b %d %a" "next Aug")} ?
 {(ftime "%Y %b %d %a" "October")} ?
 {(ftime "%Y %b %d %a" "last Oct")} ?
 {(ftime "%Y %b %d %a" "this Oct")} ?
 {(ftime "%Y %b %d %a" "next Oct")} ?

 {(ftime "%Y %b %d %a" "last year")}
 {(ftime "%Y %b %d %a" "this year")}
 {(ftime "%Y %b %d %a" "next year")}
 2022 Jul 18 Mon ?
 2022 Aug 18 Thu
 2022 Sep 18 Sun

 2022 Jun 18 Sat ?
 2022 Aug 18 Thu ?
 2022 Aug 18 Thu ?
 2022 Aug 18 Thu ?
 2022 Aug 18 Thu ?
 2022 Aug 18 Thu ?
 2022 Aug 18 Thu ?
 2022 Oct 18 Tue ?
 2022 Aug 18 Thu ?
 2022 Aug 18 Thu ?
 2022 Aug 18 Thu ?

 2021 Aug 18 Wed
 2022 Aug 18 Thu
 2023 Aug 18 Fri
 {(ftime "%Y %b %d %a" "3 wed")}
 {(ftime "%Y %b %d %a" "wed 3")} ?
 {(ftime "%Y %b %d %a" "3 wed aug")} ?
 {(ftime "%Y %b %d %a" "aug 3 wed")} ?
 {(ftime "%Y %b %d %a" "aug wed 3")} ?

 {(ftime "%Y %b %d %a" "3 wed this aug")} ?
 {(ftime "%Y %b %d %a" "this aug 3 wed")} ?
 {(ftime "%Y %b %d %a" "3 wed aug this year")} ?
 {(ftime "%Y %b %d %a" "aug this year 3 wed")} ?
 {(ftime "%Y %b %d %a" "this year aug 3 wed")} ?
 {(ftime "%Y %b %d %a" "this year aug wed 3")} ?
 2022 Sep 07 Wed
 2022 Aug 18 Thu ?
 2022 Sep 07 Wed ?
 2022 Aug 03 Wed ?
 2022 Aug 18 Thu ?

 2022 Aug 18 Thu ?
 2022 Aug 18 Thu ?
 2022 Sep 07 Wed ?
 2022 Sep 07 Wed ?
 2022 Aug 03 Wed ?
 2022 Aug 18 Thu ?

If something is unsatisfactory, the reason is the strtotime function in PHP, not PmWiki which uses the date this function recognizes and returns. See also Relative formats on which relative dates are recognized, for example "this/last/next Aug" is not among the ones that are expected to be recognized. --Petko October 19, 2014, at 06:08 AM

 0: 00.00 00.00 config start
 1: 00.01 00.01 config end
 2: 00.11 00.11 MarkupToHTML begin
 3: 00.12 00.11 MarkupToHTML begin
 4: 00.12 00.12 MarkupToHTML end
 5: 00.12 00.12 MarkupToHTML begin
 6: 00.12 00.12 MarkupToHTML end
 7: 00.12 00.12 MarkupToHTML begin
 8: 00.12 00.12 MarkupToHTML end
 9: 00.12 00.12 MarkupToHTML begin
10: 00.12 00.12 MarkupToHTML end
11: 00.12 00.12 MarkupToHTML begin
12: 00.13 00.12 MarkupToHTML end
13: 00.13 00.12 MarkupToHTML begin
14: 00.13 00.12 MarkupToHTML end
15: 00.13 00.12 MarkupToHTML begin
16: 00.13 00.12 MarkupToHTML end
17: 00.13 00.12 MarkupToHTML begin
18: 00.13 00.12 MarkupToHTML end
19: 00.13 00.12 MarkupToHTML begin
20: 00.14 00.13 MarkupToHTML end
21: 00.14 00.13 MarkupToHTML begin
22: 00.14 00.13 MarkupToHTML end
23: 00.14 00.13 MarkupToHTML begin
24: 00.14 00.14 MarkupToHTML end
25: 00.15 00.14 ReadApprovedUrls SiteAdmin.ApprovedUrls begin
26: 00.16 00.15 ReadApprovedUrls SiteAdmin.ApprovedUrls end
27: 00.17 00.16 MarkupToHTML end
28: 00.18 00.16 MarkupToHTML begin
29: 00.19 00.17 MarkupToHTML end
30: 00.19 00.17 MarkupToHTML begin
31: 00.20 00.18 MarkupToHTML end
32: 00.20 00.18 now
Peak memory: 3,433,232 bytes