daily pastebin goal
75%
SHARE
TWEET

Untitled

a guest Jan 24th, 2017 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Item
  2. {
  3.     private DateTime _checkIn;
  4.     private DateTime _checkOut;
  5.    
  6.     public Item(DateTime checkIn, DateTime checkOut) {
  7.         _checkIn = checkIn;
  8.         _checkOut = checkOut;
  9.     }
  10.  
  11.     public DateTime GetCheckInDate() => _checkIn;
  12.     public DateTime GetCheckOutDate() => _checkOut;
  13.     public void SetCheckInDate(DateTime value) => _checkIn = value;
  14.     public void SetCheckOutDate(DateTime value) => _checkOut = value;
  15.  
  16. }
  17.  
  18. void Main()
  19. {
  20.     var items = new[] {
  21.         new Item(DateTime.Parse("2017-05-01"), DateTime.Parse("2017-05-01")),
  22.         new Item(DateTime.Parse("2017-05-01"), DateTime.Parse("2017-05-10")),
  23.         new Item(DateTime.Parse("2017-05-03"), DateTime.Parse("2017-05-03")),
  24.         new Item(DateTime.Parse("2017-05-10"), DateTime.Parse("2017-05-14")),
  25.         new Item(DateTime.Parse("2017-05-12"), DateTime.Parse("2017-05-12")),
  26.         new Item(DateTime.Parse("2017-05-14"), DateTime.Parse("2017-05-19")),
  27.         new Item(DateTime.Parse("2017-05-19"), DateTime.Parse("2017-05-22"))
  28.     };    
  29.    
  30.  
  31.     var offset = items[0].GetCheckInDate().Date - DateTime.Parse("2017-01-01");
  32.  
  33.     foreach (var item in items)
  34.     {
  35.         item.SetCheckInDate(item.GetCheckInDate() - offset);
  36.         item.SetCheckOutDate(item.GetCheckOutDate() - offset);
  37.     }
  38.  
  39.     items.Select(_ => $" {_.GetCheckInDate():yyyy-MM-dd} {_.GetCheckOutDate(): yyyy-MM-dd}")
  40.         .ToList().ForEach(Console.WriteLine);
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top