Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compare_date/2,3 for comparing only the date or time portion of a provided date/time #4

Open
choptastic opened this issue Sep 13, 2013 · 0 comments

Comments

@choptastic
Copy link
Owner

Perhaps the introduction of a function compare_date/2,3 and/or compare_time/2/3.

To demonstrate the thought:

A = "2013-09-01 10am CST",
B = "2013-09-01 12pm CST",
C = "2013-09-02 12am CST",
D = "2013-09-02 12am EST",

qdate:compare_date(A,B).
%% returns 0

qdate:compare_date(A,C).
%% returns -1

qdate:compare_date(C,D).
%% returns ??. 

That last case illustrates the major issue with date comparison.

If C is converted to EST, then it's 2013-09-02 1am, where it would be the same day, whereas if D is converted to CST, then it's 2013-09-01 11pm, in which case it would be different days.

Perhaps the solution is to accept a "Reference Timezone" which both dates would be converted to, or if none is provided to use the timezone stored with set_timezone (which would fall back to GMT).

I'm not entirely sure this is a feasible proposition, and might add too much "magic".

I'd say we should just extract the date portion without even considering the timezone, but what happens when comparing against a unix timestamp or now tuple? Then we would still need to do something with implicit timezones anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant