Aren’t unix2datetime et al a good enough interface? The documented ones 
only give DateTimes, not Dates, but I guess it would be fairly easy to add 
sister methods that do that (simply by wrapping the constructor, e.g. 
unix2date(x) 
= Date(unix2datetime(x))).

// T

On Sunday, December 21, 2014 2:03:00 PM UTC+1, Avik Sengupta wrote:

I'm not sure if I like the idea of privileging a Date constructor for the 
> Rata integer, even if that is the internal representation. I'd rather have 
> consistent conversion functions for different representations, since I can 
> think of many other ways to convert an integer or a float to a Date. For 
> example,  I often need to convert an Excel date (days from 1900 or 1904, in 
> fractions). Or unix epochs. Or Julian day numbers. 
>
> Regards
> -
> Avik
>
> On Sunday, 21 December 2014 04:57:23 UTC, Jacob Quinn wrote:
>>
>> Yeah, I'd be open to changing the behavior of one-arg `Date()` if there 
>> was enough support. The reason for the current behavior is to provide 
>> consistency, i.e.:
>>
>> Date(y) -> Date(y,1,1)
>> Date(y,m) -> Date(y,m,1)
>>
>> Similarly with DateTime:
>>
>> DateTime(y,m,d) -> DateTime(y,m,d,0,0,0,0)
>> etc.
>>
>> I guess we should at least have a better API for creating a Date/DateTime 
>> from the `Dates.value(dt::Date)` integer value. 
>>
>> -Jacob
>>
>> On Sat, Dec 20, 2014 at 2:24 PM, Min-Woong Sohn <[email protected]> wrote:
>>
>>> Thank you so much!
>>>
>>>
>>> On Saturday, December 20, 2014 11:05:26 AM UTC-5, Avik Sengupta wrote:
>>>>
>>>>
>>>> julia> d2=Date(Dates.UTD(715510))
>>>> 1960-01-01
>>>>
>>>> On Saturday, 20 December 2014 03:09:42 UTC, Min-Woong Sohn wrote:
>>>>>
>>>>>
>>>>>
>>>>> Date("1960/1/1","yyyy/m/d") returns 1960-01-01, whose integer value is 
>>>>> 715510. I want to convert this integer back to Date type. How do I do 
>>>>> that? 
>>>>>
>>>>> Also I noticed that Date(1) returns 0001-01-01 and Date(2) returns 
>>>>> 0002-01-01 and Date(715510) returns 715510-01-01. Isn't this more natural 
>>>>> that Date(2) returns 0001-01-02 and Date(715510) returns 1960-01-01? Just 
>>>>> my opinion.
>>>>>
>>>>
>>  ​

Reply via email to