## Date Computations

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !

### Date Computations

Say you were introducing a new programmer to Dyalog APL. Say he wanted to compute the days difference between two dates, or do various date arithmetic, adding days to a date, etc.

Would you suggest he roll his own functions? Would you point him to a Dyalog library or workspace? Which one? Or to an external library in R or Python?
paulmansour

Posts: 283
Joined: Fri Oct 03, 2008 4:14 pm

### Re: Date Computations

..eh:
#.DateToIDN
#.IDNToDate
-wm
Veli-Matti

Posts: 44
Joined: Sat Nov 28, 2009 3:12 pm

### Re: Date Computations

Veli-Matti wrote:..eh:
#.DateToIDN
#.IDNToDate
-wm
work on only a single date so require "each" on what is an obvious array problem.
I'm not suggesting mine are perticularly quick but the same operation using APL on ten thousand dates is seven times as quick.

Phil Last

Posts: 491
Joined: Thu Jun 18, 2009 6:29 pm

### Re: Date Computations

When using DateToIDN and IDNToDate, it is worth remembering that these methods are only exposed if root properties are exposed:

Why can't I see Root Methods such as #.DateToIDN?
http://www.dyalog.com/forum/viewtopic.php?f=22&t=161

Or, you can always call these methods like this:
`      +2 ⎕nq '.' 'datetoidn' 2018 1 1843117`

Regards,

Vince
Vince|Dyalog

Posts: 302
Joined: Wed Oct 01, 2008 9:39 am

### Re: Date Computations

Let's add time to the problem. Say I want to compute the number of seconds elapsed between two time stamps.

My guess is there is no date library, or workspace with an extensive collection of date/time functions. Would that be correct?
paulmansour

Posts: 283
Joined: Fri Oct 03, 2008 4:14 pm

### Re: Date Computations

With using .Net I have contributed this to the AplWiki: https://aplwiki.com/netDateTime

PGilbert

Posts: 362
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

### Re: Date Computations

Hi Paul,

There is also the dfns.dws days and date dfns.

days ⍝ Day number from ⎕TS format.
date ⍝ ⎕TS format from day number.
`      ⎕ts2018 1 18 15 41 4 634      days ⎕ts43117.65355      ⎕ts2018 1 18 15 41 10 729      days ⎕ts43117.65361`

Regards,

Vince
Vince|Dyalog

Posts: 302
Joined: Wed Oct 01, 2008 9:39 am

### Re: Date Computations

paulmansour wrote:My guess is there is no date library, or workspace with an extensive collection of date/time functions. Would that be correct?

That is correct, and it is something we are working on. We've started a project based on the code which is shipped with MiServer https://github.com/Dyalog/MiServer/blob/master/Utils/dates.dyalog but this is somewhat oriented towards the needs of a web application. We would be very happy to receive both code contributions and suggestions for functions which should be in a complete date library.

Our intention is to make libraries of functions for date and string manipulation available on GitHub. Once we have a complete set of functions, we can talk about which parts of it (for example parsing and formatting) which we might want to rewrite in C and include in the interpreter as system functions or similar, for performance reasons.

Morten|Dyalog

Posts: 338
Joined: Tue Sep 09, 2008 3:52 pm

### Re: Date Computations

https://aplwiki.com/DateAndTime

(sometimes I feel tired)

kai

Posts: 98
Joined: Thu Jun 18, 2009 5:10 pm
Location: Stevenage, UK

### Re: Date Computations

Kai, do you know if anyone uses this library/class?
paulmansour

Posts: 283
Joined: Fri Oct 03, 2008 4:14 pm

Next

### Who is online

Users browsing this forum: No registered users and 1 guest