Test Sampler
T.A.R.D.D.I.S. (Time And Relative Date Display Information Software)
Beta Release 1.4b -- 2019/05/20

UNIX 32-bit Maximum Date is "20380118"
PHP_INT_SIZE = 4 Bytes (32 bits);  PHP_INT_MAX (Maximum Integer) is 2147483647
It is hoped that most PHP installations will be at least 64-bit well before 2035.
In the meantime, this uses a kluge to align the days of week, correctly, up to 2100/02/28

GLOBALS:
$GS_Time = "201909150642"
$GS_Today = "20190915"
$GS_Yesterday = "20190914"
$GS_Tomorrow = "20190916"
$GS_YearFromNow = "20200901"

Today, Yesterday, Tomorrow, Year from now:

a1:   GS_Date_Range ("20190915") yields: "September 15"

a2:   GS_Date_Range ("20190914") yields: "September 14"

a3:   GS_Date_Range ("20190916") yields: "September 16"

a4:   GS_Date_Range ("20200901") yields: "2020 September 1"

Current Single Dates, some with Formats:

b1:   GS_Date_Range ("20191217") yields: "December 17"

b2:   GS_Date_Range ("20191129", NULL) yields: "November 29"

b3:   GS_Date_Range ("20191015", NULL, "10") yields: "Tu, 10/15"

b4:   GS_Date_Range ("20191022", NULL, "10-") yields: "Tu, 10‑22"

b5:   GS_Date_Range ("20191023", NULL, "10–") yields: "W, 10–23"
          (Showing an n-dash as a delimiter between month and date)

b6:   GS_Date_Range ("20190624", NULL, "3") yields: "Mon, 2019 June 24"

b7:   GS_Date_Range ("20190704", NULL, "3.3") yields: "Thu., 2019 Jul 4"

b8:   GS_Date_Range ("20190725", NULL, "33.") yields: "Thu, 2019 Jul. 25"

Far Future Single Dates:

c1:   GS_Date_Range ("20201217") yields: "2020 December 17"

c2:   GS_Date_Range ("20201129", NULL) yields: "2020 November 29"

c3:   GS_Date_Range ("20200905", NULL, "10") yields: "Sa, ’20/09/05"

c4:   GS_Date_Range ("20201015", NULL, "10") yields: "Th, ’20/10/15"

c5:   GS_Date_Range ("20201023", NULL, "10-") yields: "F, ’20‑10‑23"

c6:   GS_Date_Range ("20201023", NULL, "11-") yields: "F, ’20‑10‑23"

c7:   GS_Date_Range ("20200413", NULL, "11-") yields: "M, 4‑13"

c8:   GS_Date_Range ("20200405", NULL, "11-") yields: "Su, 4‑5"

c9:   GS_Date_Range ("20210624", NULL, "3") yields: "Thu, 2021 June 24"

c10:   GS_Date_Range ("20210704", NULL, "3.3") yields: "Sun., 2021 Jul 4"

c11:   GS_Date_Range ("20210725", NULL, "33.") yields: "Sun, 2021 Jul. 25"

c12:   GS_Date_Range ("20181017", NULL, "6)2>") yields: "Wednes), 2018 Oc> 17"
          (Showing silly delimiters)

Two Dates (Date Range):

d1:   GS_Date_Range ("20181217", "20181221") yields: "2018 December 17‑21"

d2:   GS_Date_Range ("20181016", "20181121") yields: "2018 October 16 to November 21"

d3:   GS_Date_Range ("20191114", "20191128") yields: "November 14‑28"

d4:   GS_Date_Range ("20181112", "20181121", "01") yields: "’18/11/12‑21"

d5:   GS_Date_Range ("20180913", "20200102", "03.") yields: "2018 Sep. 13 to 2020 Jan. 2"
          (Span multiple years, forcing years to be shown)

d6:   GS_Date_Range ("20180901", "20200311", "05.") yields: "2018 Septe. 1 to 2020 March 11"

d7:   GS_Date_Range ("20180430", "20200222", "00") yields: "’18/04/30 to ’20/02/22"

d8:   GS_Date_Range ("20180330", "20200106", "01") yields: "’18/3/30 to ’20/1/6"

Delimiters:

e1:   GS_Date_Range ("20181217", "20181221", "38", "D: - ") yields: "Mon‑Fri, 2018 December 17 - 21"

e2:   GS_Date_Range ("20181016", "20181121", "3.5.", "W: to ", "M:-") yields: "Tue., 2018 Octob. 16-Wed., Novem. 21"
          (Switch week and month delimiters)

Delimiters with Color Codes:

e3:   GS_Date_Range ("20190916", "20191128", NULL, "C", "M: Thru ") yields: " September 16 Thru November 28 "

e4:   GS_Date_Range ("20190914", "20200928", NULL, "C") yields: " 2019 September 14 to 2020 September 28 "

Two Dates with Days-of-Week:  (less than a week apart)

f1:   GS_Date_Range ("20181112", "20181118", "11") yields: "M‑Su, ’18/11/12‑18"

f2:   GS_Date_Range ("20181112", "20181118", "2.9") yields: "Mo.‑Su., 2018 November 12‑18"

f3:   GS_Date_Range ("20190913", "20190919", "43.") yields: "Frid‑Thur, Sep. 13‑19"

Two Dates with Days-of-Week:  (more than a week apart)

f4:   GS_Date_Range ("20181112", "20181122", "11") yields: "M, ’18/11/12 to Th, 11/22"

f5:   GS_Date_Range ("20181112", "20181122", "2.9") yields: "Mo., 2018 November 12 to Th., November 22"

f6:   GS_Date_Range ("20180913", "20200102", "43.") yields: "Thur, 2018 Sep. 13 to Thur, 2020 Jan. 2"

f7:   GS_Date_Range ("20180901", "20200311", "3.5.") yields: "Sat., 2018 Septe. 1 to Wed., 2020 March 11"

f8:   GS_Date_Range ("20180430", "20200222", "20") yields: "Mo, ’18/04/30 to Sa, ’20/02/22"

f9:   GS_Date_Range ("20170330", "20190106", "11") yields: "Th, ’17/3/30 to Su, ’19/1/6"

Test "last" and "next" year fields:

g1:   GS_Date_Range ("last0521", "next0605", NULL, "C") yields: " 2019 May 21 to 2020 June 5 "

g2:   GS_Date_Range ("last0902", "next1111", NULL, "P") yields: "September 2 to November 11"

g3:   GS_Date_Range ("last0916", "next0914", NULL, "C") yields: " 2018 September 16 to 2020 September 14 "

g4:   GS_Date_Range ("Last0916", "Next0914", NULL, "P") yields: "2018 September 16 to 2020 September 14"

g5:   GS_Date_Range ("last0914", "next0916", NULL, "P") yields: " September 14‑16 "

g6:   GS_Date_Range ("Last0914", "Next0916", NULL, "C") yields: " September 14‑16 "

g7:   GS_Date_Range ("Last0914", "Next0916", NULL, "P") yields: " September 14‑16 "

Using "K" command to position the Days-of-the-Week:

h1:   GS_Date_Range ("20190821", "20190826", "24.") yields: "We‑Mo, 2019 Augu. 21‑26"

h2:   GS_Date_Range ("20190821", "20190826", "24.", "K") yields: "We, 2019 Augu. 21 to Mo, Augu. 26"

h3:   GS_Date_Range ("20190821", "20190831", "24.") yields: "We, 2019 Augu. 21 to Sa, Augu. 31"

h4:   GS_Date_Range ("20190821", "20190831", "24.", "K12") yields: "We‑Sa, 2019 Augu. 21‑31"

h5:   GS_Date_Range ("last1217", "next1217", "23.") yields: "Mo, 2018 Dec. 17 to Tu, 2019 Dec. 17"

h6:   GS_Date_Range ("last1217", "next1217", "23.", "K") yields: "Mo, 2018 Dec. 17 to Tu, 2019 Dec. 17"

h7:   GS_Date_Range ("last1217", "next1217", "23.", "K:900") yields: "Mo‑Tu, 2018 Dec. 17 to 2019 Dec. 17"

"Until ":

i1:   GS_Date_Range ("20180901", "20191111", "3.5.", "U") yields: "until Mon., Novem. 11"

i2:   GS_Date_Range ("20180901", "20201111", "3.5.", "U") yields: "until Wed., 2020 Novem. 11"

i3:   GS_Date_Range ("20180901", "20200111", "3.5.", "U") yields: "until Sat., Janua. 11"

i4:   GS_Date_Range ("20180901", "20200311", "3.5.", "U") yields: "until Wed., March 11"

i5:   GS_Date_Range ("20180430", "20200222", "20", "U") yields: "until Sa, 02/22"

i6:   GS_Date_Range ("20180330", "20200106", "11", "U") yields: "until M, 1/6"

i7:   GS_Date_Range ("20191112", "20191122", "11", "U:Continuing ’till ") yields: "Tu, 11/12 to F, 11/22"

i8:   GS_Date_Range ("20180913", "20200102", "43.", "U:Continuing ’till ") yields: "Continuing ’till Thur, Jan. 2"

Until with Color Codes:

j1:   GS_Date_Range ("20180430", "20200222", "20", "C", "U") yields: " until Sa, 02/22 "

j2:   GS_Date_Range ("20190914", "20200106", "11", "U", "C") yields: " until M, 1/6 "

j3:   GS_Date_Range ("20190915", "20200222", "20", "U", "C") yields: " Su, 09/15 to Sa, 02/22 "

j4:   GS_Date_Range ("20190916", "20200106", "11", "U", "C") yields: " M, 9/16 to M, 1/6 "

Portal / Paper / Proposal Range:

k1:   GS_Date_Range ("20180822", "20201123", "03.", "P") yields: "2018 Aug. 22 to 2020 Nov. 23"

k2:   GS_Date_Range ("20180822", "20190916", "03", "P") yields: " 2018 Aug 22 to 2019 Sep 16 "

k3:   GS_Date_Range ("20180822", "20190915", "09.", "P") yields: " 2018 August 22 to 2019 September 15 "

k4:   GS_Date_Range ("20180822", "20190914", NULL, "P") yields: " 2018 August 22 to 2019 September 14 "

k5:   GS_Date_Range (NULL, "20190914", NULL, "P") yields: " September 14 "

k6:   GS_Date_Range ("20181123", NULL, "03.", "P") yields: " 2018 Nov. 23 "

k7:   GS_Date_Range ("20190916", NULL, "03", "P") yields: " Sep 16 "

k8:   GS_Date_Range ("20190915", NULL, "09.", "P") yields: " September 15 "

k9:   GS_Date_Range ("20190914", NULL, NULL, "P") yields: " September 14 "

Prefixes and Suffixes:

m1:   GS_Date_Range ("20190914", "20191006", "01", "U:Valid until ", "C", "M: through ", "p:Valid from ", "s: 5:00 pm PDT") yields: " Valid until 10/6 5:00 pm PDT "

m2:   GS_Date_Range ("20190916", "20200901", NULL, "U:Valid until ", "C", "M: through ", "p:Valid from ", "s: 8:00 pm EDT") yields: " Valid from 2019 September 16 through 2020 September 1 8:00 pm EDT "

m3:   GS_Date_Range ("20160731", "20190816", "01", "U:Valid until ", "P", "M: through ", "p:Valid from ") yields: " Valid until ’19/8/16 "

m4:   GS_Date_Range ("20180731", "20190816", "01", "U:Only valid until ", "P", "M: through ", "p:Valid from ") yields: " Only valid until ’19/8/16 "

m5:   GS_Date_Range ("20160731", "20200816", "01", "U:Only valid until ", "P", "M: through ", "p:Valid from ") yields: "Only valid until 8/16"

m6:   GS_Date_Range ("20160731", "20190916", "01", "U:Only valid until ", "P", "M: through ", "p:Valid from ") yields: " Only valid until 9/16 "

m7:   GS_Date_Range ("20160731", "20190915", "01", "U:Only valid until ", "P: 8", "M: through ", "p:Valid from ") yields: " Only valid until 9/15 "
          (Paper-due "P" color is '8' (gray), but not used here)

m8:   GS_Date_Range ("20170731", "20190914", "01", "U:Only valid until ", "P", "M: through ", "p:Valid from ") yields: " Only valid until 9/14 "

m9:   GS_Date_Range ("20170731", "20190914", "01", "U:Only valid until ", "P:--8", "M: through ", "p:Valid from ") yields: " Only valid until 9/14 "
          ("P" color is '8' (gray), used here)

"X" = Expired:

n1:   GS_Date_Range ("20180521", "20180630", "13.", "P:z", "p: is Open from ", "U: is Open Until ", "M: thru ", "X") yields: " is CLOSED "

n2:   GS_Date_Range ("20160521", "20190916", "13.", "P:z", "p: is Open from ", "U: is Open Until ", "M: thru ", "X") yields: " is Open Until M, Sep. 16 "
          (Paper-due "P" color is 'z' (bronze))

n3:   GS_Date_Range ("20160521", "20190915", "13.", "P:z", "p: is Open from ", "U: is Open Until ", "M: thru ", "X") yields: " is Open Until Su, Sep. 15 "

n4:   GS_Date_Range ("20160521", "20190914", "13.", "P:z", "p: is Open from ", "s: (firm)", "U: is Open Until ", "M: thru ", "X") yields: " is CLOSED "

n5:   GS_Date_Range ("201901122", "20190914", "13.", "P:z", "p: is Open from ", "s: (firm)", "U: is Open Until ", "M: thru ", "X:has ended") yields: " has ended "

Dates out of order, or invalid:  (Diagnostics appear only when $GS_ShowTimeError is TRUE)

o1:   GS_Date_Range ("20190921", "20190802") yields:
BAD DATE RANGE (GS_Date_Range): 20190921 to 20190802
"2019 September 21 to August 2"

o2:   GS_Date_Range ("20181031", "20180902", "00") yields:
BAD DATE RANGE (GS_Date_Range): 20181031 to 20180902
"’18/10/31 to 09/02"

TOO MANY DAYS IN MONTH (02/29) (GS_Date_Range): 20190229

o3:   GS_Date_Range ("20190229", "20190323") yields: "2019 March 29 to March 23"

o4:   GS_Date_Range ("20200229", "20200323") yields: "February 29 to March 23"
          (… but 02/29 is OK for Leap Year)

DATE CONTAINS NON-NUMERIC CHARACTER, 'O' (GS_Date_Range): 2019O323

o5:   GS_Date_Range ("20190531", "2019O323") yields: "2019 May 31 to December 23"

MONTH "14" IS NOT BETWEEN 01 AND 12 (GS_Date_Range): 20191431

MONTH "00" IS NOT BETWEEN 01 AND 12 (GS_Date_Range): 20190023

o6:   GS_Date_Range ("20191431", "20190023") yields:
BAD DATE RANGE (GS_Date_Range): 20191431 to 20190023
"2019 December 31 to December 23"

Duplicate and Unknown Commands:  (Diagnostics appear only when $GS_ShowTimeError is TRUE)

o7:   GS_Date_Range ("20160731", "20190916", "01", "U:Only valid until ", "P", "M: through ", "p:Valid from ", "U:Valid until ") yields:
DUPLICATE COMMAND "U:Valid until " (GS_Date_Range)
" Valid until 9/16 "

o8:   GS_Date_Range ("20180515", NULL, "10", "b", "C", "B") yields:
DUPLICATE COMMAND "B" (GS_Date_Range)
" Tu, ’18/05/15 "
                  before: Tu, ’18/05/15
                   after: Tu, ’18/05/15

o9:   GS_Date_Range ("20190916", NULL, "3.3.", "Q") yields:
BAD GS_Date_Range COMMAND "Q"
"Mon., Sep. 16"

"Century" test – Days of Week not accurate after 2100/02/28:

p1:   GS_Date_Range ("19970222", "21010101", "01") yields: "1997/2/22 to 2101/1/1"

p2:   GS_Date_Range ("20210223", "21400223", "00") yields: "’21/02/23 to 2140/02/23"

p3:   GS_Date_Range ("20371025", "21610225", "00") yields: "’37/10/25 to 2161/02/25"

p4:   GS_Date_Range ("20380226", "21610227", "00") yields: "’38/02/26 to 2161/02/27"

Making output strings Binding (Non-Breaking) or semi-binding:  (“” denotes space; “&” denotes ampersand)

q1:   GS_Date_Range ("20160731", "20190916", "01", "U:Only–valid until ", "P", "M: through ", "p:Valid from ", "B") yields: " Only–valid  until 9/16 "
                  before: Only–validuntil9/16
                   after: Only–valid  until 9/16

q2:   GS_Date_Range ("20171015", NULL, "10", "b") yields: "Su, ’17/10/15"
                  before: Su, ’17/10/15
                   after: Su,’17/10/15

q3:   GS_Date_Range ("20200725", NULL, "33=", "b:=") yields: "Sat, Jul= 25"
                  before: Sat, Jul= 25
                   after: Sat, Jul=25

q4:   GS_Date_Range ("20200725", NULL, "33=", "b:,:;=") yields: "Sat, Jul= 25"
                  before: Sat, Jul= 25
                   after: Sat,Jul=25

q5:   GS_Date_Range ("20200725", NULL, "33>", "b:,:;>") yields: "Sat, Jul> 25"
                  before: Sat, Jul> 25
                   after: Sat,Jul>25

q6:   GS_Date_Range ("20200725", NULL, "33>", "b:,:;>") yields: "Sat, Jul> 25"
                  before: Sat, Jul> 25
                   after: Sat,Jul>25

Demonstrating the use of the "b" command with an HMTL character code ("&-----;"):

q7:   GS_Date_Range ("20180725", NULL, "3–3⇛") yields: "Wed–, 2018 Jul⇛ 25"

q8:   GS_Date_Range ("20190725", NULL, "3–3⇛", "b") yields: "Thu–, 2019 Jul⇛ 25"
                  before: Thu–, 2019 Jul⇛ 25
                   after: Thu–,2019 Jul⇛25

Mandatory Year Command:  (as part of date)

r1:   GS_Date_Range ("last0412+", "Next1112", "15.", "U") yields: "until Tu, Novem. 12"

r2:   GS_Date_Range ("next1216+", "20201112", "15.", "U") yields: "M, 2019 Decem. 16 to Th, 2020 Novem. 12"

r3:   GS_Date_Range ("20190516", "20191112", "15.") yields: "Th, 2019 May 16 to Tu, Novem. 12"

r4:   GS_Date_Range ("last1216", "20191112+", "15.", "U") yields: "until Tu, 2019 Novem. 12"

r5:   GS_Date_Range ("last1216", "20191112*", "15.") yields: "Su, 2018 Decem. 16 to Tu, 2019 Novem. 12"

r6:   GS_Date_Range ("next0714", "20191112+", "15.", "U") yields:
BAD DATE RANGE (GS_Date_Range): 20200714 to 20191112
"Tu, 2020 July 14 to Tu, 2019 Novem. 12"

r7:   GS_Date_Range ("last0814-", "next1112", "23.") yields: "We, Aug. 14 to Tu, Nov. 12"

Mandatory Year Command:  (as sep. argument, and as part of date)

s1:   GS_Date_Range ("last0412", "20200312", "23.", "U") yields: "until Th, Mar. 12"
          (Ending date within about a year: Year not shown)

s2:   GS_Date_Range ("last0312", "20201113", "23.", "U") yields: "until Fr, 2020 Nov. 13"
          (Ending date beyond about a year: Year is shown)

s3:   GS_Date_Range ("next1216", "20201112", "23.", "U", "Y") yields: "Mo, 2019 Dec. 16 to Th, 2020 Nov. 12"
          ("Y" forces year to be shown in both dates, for consistency)

s4:   GS_Date_Range ("20190516", "20211112", "33.", "Y-") yields: "Thu, May.16 to Fri, Nov. 12"
          ("Y-" suppresses years; notice hidden period in "May.", sweep over it to see)

s5:   GS_Date_Range ("last1216", "20191112+", "23.", "U", "Y-") yields: "until Tu, Nov. 12"
          ("Y-" trumps '+' after date, year not shown)

s6:   GS_Date_Range ("last1216", "20191112*", "23.", "U", "Y-") yields: "until Tu, 2019 Nov. 12"
          ('*' after date trumps "Y-", year is shown)

s7:   GS_Date_Range ("next0714-", "20191112+", "33.", "U", "Y") yields:
BAD DATE RANGE (GS_Date_Range): 20200714 to 20191112
"Tue, 2020 Jul. 14 to Tue, 2019 Nov. 12"

s8:   GS_Date_Range ("last0814", "next1112", "23.", "Y-") yields: "We, Aug. 14 to Tu, Nov. 12"

s9:   GS_Date_Range ("last1216", "20191112-", "23.", "Y+") yields: "Su, 2018 Dec. 16 to Tu, Nov. 12"
          ('-' after date trumps "Y+", year not shown)

Copyright © 2017-19 Joshua Zev Levin, Ph.D.