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

Subtract time #38

Closed
tommyjcarpenter opened this issue Apr 27, 2017 · 2 comments
Closed

Subtract time #38

tommyjcarpenter opened this issue Apr 27, 2017 · 2 comments
Labels
Milestone

Comments

@tommyjcarpenter
Copy link

Is there a negative or inverse of add_time?

@grantwinney
Copy link

grantwinney commented Jul 7, 2017

There's no function for it in this library, but you could just use negative numbers:

% show current time
> calendar:local_time().
{{2017,7,7},{15,5,42}}

% subtract 2 hours, 3 minutes, 4 seconds
> iso8601:add_time(calendar:local_time(), -2, -3, -4).
{{2017,7,7},{13,2,38}}

You could even define your own function for convenience:

Subtract = fun(Datetime, H, M, S) -> iso8601:add_time(Datetime, -H, -M, -S) end.

% show current time
> calendar:local_time().
{{2017,7,7},{15,10,39}}

% subtract 2 hours, 3 minutes, 10 seconds
> Subtract(calendar:local_time(), 2, 3, 10).
{{2017,7,7},{13,7,29}}

@oubiwann
Copy link
Member

We can definitely add this.

@oubiwann oubiwann changed the title how to subtract time Subtract time Aug 11, 2017
@oubiwann oubiwann added this to the 1.3 milestone Nov 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants