This language bar is your friend. Select your favorite languages!

Idiom #115 Compare dates

Set boolean b to true if date d1 is strictly before date d2 ; false otherwise.

extern crate chrono;
use chrono::prelude::*;
let b = d1 < d2;
bool b = d1 < d2;
import std.datetime;
bool b = d1 < d2;
import "time"
b := d1.Before(d2)
import Data.Time.Calendar
b = d1 < d2
import java.util.Date;
boolean before = (d1.compareTo(d2) == -1);
$d1 = new DateTime('January 25 2016');
$d2 = new DateTime('January 26 2016');

$b = $d1 < $d2;
uses dateutils;
b := (CompareDateTime(d1,d2) = -1);
my $b = d1 < d2;
import datetime
b = d1 < d2
b = d1 < d2

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

programming-idioms.org