SplitDate

Transform an array of integer scalars representing YYYYMMDD into an array of 1 higher rank with three columns representing YYY MM DD.

      ⍉0 100 100⊤ISV

Examples

      0 100 100⊤⍉20100102 
2010 1 2
      ⍉0 100 100⊤⍉20100102 19991231
2010  1  2
1999 12 31
      ⍉0 100 100⊤⍉2 2⍴20100102 19991231 30000101 30001231
2010  1  2
1999 12 31
          
3000  1  1
3000 12 31

The initial transpose on the right, which is redundant for scalar or vector IA, ensures that all other dimensions return to the correct order after the second transpose with the new first dimension moved to the last position.

Compatibility

Checked with: APL2, APLX, Dyalog, NARS2000

Test Cases

Show test cases

Test
 ⎕IO←0      ⍝ You may change this; however, zero IS the default in the Phrasebook 
  ⎕FX ⍕2 1⍴'r←JoinDate y' 'r←⍉0 100 100⊤⍉y'   
⍝ ---- Start Test cases (do not delete this!)
2010 8 29 ≡ JoinDate 20100829
2010 12 31 ≡ JoinDate 20101231
(2 2 3⍴2010 12 31 1999 6 30 3000 1 1 3000 12 31)≡(JoinDate 2 2⍴20101231 19990630 30000101 30001231)
(0 3⍴⍳0)≡⍉0 100 100⊤⍳0

For details see the PhraseBook/TestCasesGuidelines.

Test my code, both Examples and Test Cases.

See also: JoinDate

Mentor: KaiJaeger

Tags: <TransformDate> <IntAsDate>


CategoryPhrasesAll - CategoryPhraseDates

PhraseBook/SplitDate (last edited 2011-12-26 10:33:48 by KaiJaeger)