Created
          October 4, 2015 21:09 
        
      - 
      
- 
        Save tugberkugurlu/eb81ce166aaff7021ed3 to your computer and use it in GitHub Desktop. 
    trying out ZonedDateTimeSerializer
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var mongoDatabase1 = ConfigureAndGetMongoDatabase(); | |
| var racesCollection = mongoDatabase1.GetCollection<RaceEntity>("races"); | |
| racesCollection.Drop(); | |
| DateTimeZone london = DateTimeZoneProviders.Tzdb["Asia/Istanbul"]; | |
| LocalDateTime local = new LocalDateTime(1955, 3, 15, 0, 45, 00); | |
| ZonedDateTime londonTime = london.AtStrictly(local); | |
| var race = new RaceEntity("foo", londonTime, "bar"); | |
| try | |
| { | |
| await racesCollection.InsertOneAsync(race); | |
| } | |
| catch(Exception e) | |
| { | |
| Console.WriteLine(e.ToString()); | |
| return; | |
| } | |
| try | |
| { | |
| var race2 = await racesCollection.Find(Builders<RaceEntity>.Filter.Eq(x => x.Id, race.Id)).FirstOrDefaultAsync(); | |
| Console.WriteLine(race2.RaceDateTime == londonTime); | |
| Console.WriteLine(race2.RaceDateTime.ToString()); | |
| } | |
| catch(Exception e) | |
| { | |
| Console.WriteLine(e.ToString()); | |
| return; | |
| } | |
| return; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
list of time zone ids: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones