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

Postby paulmansour on Wed Jan 17, 2018 9:55 pm

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: 262
Joined: Fri Oct 03, 2008 4:14 pm

Re: Date Computations

Postby Veli-Matti on Thu Jan 18, 2018 7:01 am

..eh:
#.DateToIDN
#.IDNToDate
-wm
Veli-Matti
 
Posts: 28
Joined: Sat Nov 28, 2009 3:12 pm

Re: Date Computations

Postby Phil Last on Thu Jan 18, 2018 9:25 am

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.
User avatar
Phil Last
 
Posts: 464
Joined: Thu Jun 18, 2009 6:29 pm

Re: Date Computations

Postby Vince|Dyalog on Thu Jan 18, 2018 9:36 am

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 18
43117


Regards,

Vince
Vince|Dyalog
 
Posts: 276
Joined: Wed Oct 01, 2008 9:39 am

Re: Date Computations

Postby paulmansour on Thu Jan 18, 2018 2:51 pm

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: 262
Joined: Fri Oct 03, 2008 4:14 pm

Re: Date Computations

Postby PGilbert on Thu Jan 18, 2018 2:54 pm

With using .Net I have contributed this to the AplWiki: https://aplwiki.com/netDateTime
User avatar
PGilbert
 
Posts: 361
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: Date Computations

Postby Vince|Dyalog on Thu Jan 18, 2018 3:46 pm

Hi Paul,

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

days ⍝ Day number from ⎕TS format.
date ⍝ ⎕TS format from day number.
      ⎕ts
2018 1 18 15 41 4 634
days ⎕ts
43117.65355


⎕ts
2018 1 18 15 41 10 729
days ⎕ts
43117.65361


Regards,

Vince
Vince|Dyalog
 
Posts: 276
Joined: Wed Oct 01, 2008 9:39 am

Re: Date Computations

Postby Morten|Dyalog on Fri Jan 19, 2018 9:43 am

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.
User avatar
Morten|Dyalog
 
Posts: 316
Joined: Tue Sep 09, 2008 3:52 pm

Re: Date Computations

Postby kai on Fri Jan 19, 2018 2:11 pm

https://aplwiki.com/DateAndTime

(sometimes I feel tired)
User avatar
kai
 
Posts: 91
Joined: Thu Jun 18, 2009 5:10 pm
Location: Stevenage, UK

Re: Date Computations

Postby paulmansour on Fri Jan 19, 2018 5:52 pm

Kai, do you know if anyone uses this library/class?
paulmansour
 
Posts: 262
Joined: Fri Oct 03, 2008 4:14 pm

Next

Return to APL Chat

Who is online

Users browsing this forum: No registered users and 1 guest