TestFtime


ftime test

* {(ftime '%B %Y' '-1 month')} - ({(ftime '%m' '-1 month')})
* {(ftime '%B %Y' '+0 month')} - ({(ftime '%m' '+0 month')})
* {(ftime '%B %Y'           )} - ({(ftime '%m'           )})
* {(ftime '%B %Y' '+1 month')} - ({(ftime '%m' '+1 month')}) -- bug? - expect Apr
* {(ftime '%B %Y' '+2 month')} - ({(ftime '%m' '+2 month')}) -- bug? - expect May
* {(ftime '%B %Y' '+3 month')} - ({(ftime '%m' '+3 month')}) -- bug? - expect Jun

* {(ftime '%B %Y' 'next month')} - ({(ftime '%m' 'next month')}) -- bug? - expect Apr
* {(ftime fmt='%A, %d %B %Y, %Hh%M' "Apr")} -- bug? - expect Apr

  • September 2024 - (09)
  • October 2024 - (10)
  • October 2024 - (10)
  • November 2024 - (11) -- bug? - expect Apr
  • December 2024 - (12) -- bug? - expect May
  • January 2025 - (01) -- bug? - expect Jun
  • November 2024 - (11) -- bug? - expect Apr
  • Monday, 08 April 2024, 00h00 -- bug? - expect Apr
oh no! where is April ??

Because today is March 31, it adds or removes 1 month as in "February 31" and "April 31" which do not exist and are recalculated to 2020-03-02 and 2020-05-01, see https://stackoverflow.com/questions/14584115/. --Petko March 31, 2020, at 04:00 PM

!!!! Is this a likely solution ?
(:if ! equal {(ftime '%m' 'next month')} {(ftime '%m')}:)
* {(ftime '%B %Y' '+3 days')} - ({(ftime '%m' '+3 days')}) 'IF 1, expect Apr \0/'
(:else:)
* {(ftime '%B %Y' 'next month')} - ({(ftime '%m' 'next month')}) 'IF 2'
(:ifend:)

Is this a likely solution ?

  • October 2024 - (10) 'IF 1, expect Apr \0/'

VKrishn March 31, 2020, at 04:32 PM

You can do nested ftime: --Petko March 31, 2020, at 04:57 PM

inside:  15th of the current month: {(ftime "%Y-%m-15")}
* inside+1month: {(ftime when=(ftime "%Y-%m-15")+1month fmt="%B %Y")}
* inside-1month: {(ftime when=(ftime "%Y-%m-15")-1month fmt="%B %Y")}
* inside+2months: {(ftime when=(ftime "%Y-%m-15")+2month fmt="%B %Y")}

inside: 15th of the current month: 2024-10-15

  • inside+1month: November 2024
  • inside-1month: September 2024
  • inside+2months: December 2024
thanks, this works!, VKrishn March 31, 2020, at 06:56 PM

!!!! This could also work
(:if equal {(mod (ftime '%m' 'next month') (ftime '%m'))} 2:)
* {(ftime '%B %Y' '+3 days')} - ({(ftime '%m' '+3 days')}) 'IF 1, expect Apr \0/'
(:else:)
* {(ftime '%B %Y' 'next month')} - ({(ftime '%m' 'next month')}) 'IF 2'
(:ifend:)

This could also work

  • November 2024 - (11) 'IF 2'

VKrishn March 31, 2020, at 07:06 PM

 0: 00.00 00.00 config start
 1: 00.01 00.01 config end
 2: 00.21 00.20 MarkupToHTML begin
 3: 00.21 00.20 MarkupToHTML begin
 4: 00.22 00.21 MarkupToHTML end
 5: 00.22 00.21 MarkupToHTML begin
 6: 00.22 00.21 MarkupToHTML end
 7: 00.22 00.21 MarkupToHTML begin
 8: 00.22 00.21 MarkupToHTML end
 9: 00.22 00.21 MarkupToHTML begin
10: 00.22 00.21 MarkupToHTML end
11: 00.23 00.22 ReadApprovedUrls SiteAdmin.ApprovedUrls begin
12: 00.23 00.22 ReadApprovedUrls SiteAdmin.ApprovedUrls end
13: 00.33 00.31 MarkupToHTML end
14: 00.34 00.31 MarkupToHTML begin
15: 00.35 00.33 MarkupToHTML end
16: 00.35 00.33 MarkupToHTML begin
17: 00.35 00.33 MarkupToHTML end
18: 00.36 00.33 now
Peak memory: 3,735,648 bytes