Attachment 'netDateTime.v1.0.txt'

Download

   1 :Namespace netDateTime
   2 
   3    ⍝ Functions related to Dates and Time
   4 
   5     (⎕IO ⎕ML ⎕WX)←1 3 3
   6 
   7       DayOfWeek←{
   8          ⍝ ⍵ = .Net Date Object
   9          ⍝ Result = Day of the Week as a Number (Sunday = 1)
  10      
  11           ⎕USING←'System,mscorlib.dll'
  12           1+Int32 ⎕CLASS ⍵.DayOfWeek
  13       }
  14 
  15       FormatDate←{
  16         ⍝ ⍵ = .Net Date Object
  17         ⍝ ⍺ = Format String
  18         ⍝ Result = Date formatted to a String
  19      
  20           ⎕USING←'System,mscorlib.dll' 'System.Xml,System.Xml.dll'
  21           XmlConvert.ToString(⍵(,⍺))
  22       }
  23       
  24     ∇ r←NowToDateString;⎕USING
  25     ⍝ r = Current Date formatted to a String
  26      
  27       ⎕USING←'System,mscorlib.dll' 'System.Xml,System.Xml.dll'
  28       r←XmlConvert.ToString((DateTime.Now)(,'dddd MMMM d yyyy'))
  29 
  30 
  31     ∇ r←NowToTimeString;⎕USING
  32     ⍝ r = Current Time formatted to a String
  33      
  34       ⎕USING←'System,mscorlib.dll' 'System.Xml,System.Xml.dll'
  35       r←XmlConvert.ToString((DateTime.Now)(,'HH:mm:ss'))
  36 
  37 
  38       OADateToDateObj←{
  39          ⍝ ⍵ = OADate as a number
  40          ⍝ Result = .Net Date Object
  41      
  42           ⎕USING←'System,mscorlib.dll'
  43           DateTime.FromOADate ⍵
  44       }
  45 
  46       OADateToDateString←{
  47         ⍝ ⍵ = OADate as a number
  48         ⍝ Result = Date formatted to a String
  49      
  50           ⎕USING←'System,mscorlib.dll' 'System.Xml,System.Xml.dll'
  51           XmlConvert.ToString((DateTime.FromOADate ⍵)(,'dddd, MMMM d, yyyy'))
  52       }
  53 
  54       OADateToTimeString←{
  55         ⍝ ⍵ = OADate as a number
  56         ⍝ Result = Time formatted to a String
  57      
  58           ⎕USING←'System,mscorlib.dll' 'System.Xml,System.Xml.dll'
  59           XmlConvert.ToString((DateTime.FromOADate ⍵)(,'HH:mm:ss'))
  60       }
  61       
  62       OADateToTs←{
  63         ⍝ ⍵ = OADate as a number
  64         ⍝ Result = ⎕TS
  65      
  66           ⎕USING←'System,mscorlib.dll'
  67           ⍺←DateTime.FromOADate ⍵
  68           ⍺.(Year Month Day Hour Minute Second Millisecond)
  69       }
  70       
  71       TsToDateObject←{
  72         ⍝ ⍵ = ⎕TS
  73         ⍝ Result = .Net Date Object
  74      
  75           ⎕USING←'System,mscorlib.dll'
  76           ⎕NEW DateTime ⍵
  77       }
  78 
  79       TsToDateString←{
  80         ⍝ ⍵ = ⎕TS
  81         ⍝ Result = Date formatted to a String
  82      
  83           ⎕USING←'System,mscorlib.dll' 'System.Xml,System.Xml.dll'
  84           XmlConvert.ToString(((⎕NEW DateTime ⍵))(,'dddd, MMMM d, yyyy'))
  85       }
  86 
  87       TsToDayOfWeek←{
  88         ⍝ ⍵ = ⎕TS
  89         ⍝ Result = Day of the week
  90      
  91           ⎕USING←'System,mscorlib.dll'
  92           (⎕NEW DateTime ⍵).DayOfWeek
  93       }
  94 
  95       TsToOADate←{
  96         ⍝ ⍵ = ⎕TS
  97         ⍝ Result = OADate as a number
  98      
  99           ⎕USING←'System,mscorlib.dll'
 100           (⎕NEW DateTime ⍵).ToOADate
 101       }
 102       
 103       TsToTimeString←{
 104         ⍝ ⍵ = OADate as a number
 105         ⍝ Result = Time formatted to a String
 106      
 107           ⎕USING←'System,mscorlib.dll' 'System.Xml,System.Xml.dll'
 108           XmlConvert.ToString(((⎕NEW DateTime ⍵))(,'HH:mm:ss'))
 109       }
 110 
 111 :EndNamespace

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2015-02-18 18:22:39, 3.2 KB) [[attachment:netDateTime.v1.0.txt]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.