<commit_before>package de.zalando.play.controllers

import org.joda.time.DateTime
import org.scalatest.{MustMatchers, FunSpec}

/**
  * @author slasch 
  * @since 04.01.2016.
  */
class Rfc3339UtilTest extends FunSpec with MustMatchers {

  val date = new DateTime(1451911387284L)

  describe("Rfc3339UtilTest") {

    it("should parse RFC3339 DateTime") {
      Rfc3339Util.parseDateTime("2007-05-01T15:43:26-07:00").toString mustBe "2007-05-02T00:43:26.000+02:00"
      Rfc3339Util.parseDateTime("2007-05-01T15:43:26.3-07:00").toString mustBe "2007-05-02T00:43:26.300+02:00"
      Rfc3339Util.parseDateTime("2007-05-01T15:43:26.3452-07:00").toString mustBe "2007-05-02T00:43:26.345+02:00"
      Rfc3339Util.parseDateTime("2007-05-01T15:43:26.3452Z").toString mustBe "2007-05-01T15:43:26.345+02:00"
      Rfc3339Util.parseDateTime("2007-05-01T15:43:26.3Z").toString mustBe "2007-05-01T15:43:26.300+02:00"
      Rfc3339Util.parseDateTime("2007-05-01T15:43:26Z").toString mustBe "2007-05-01T15:43:26.000+02:00"
    }
    it("should parse RFC3339 Date") {
      Rfc3339Util.parseDate("2007-05-01").toString mustBe "2007-05-01T00:00:00.000+02:00"
      Rfc3339Util.parseDate("2008-05-01").toString mustBe "2008-05-01T00:00:00.000+02:00"
      Rfc3339Util.parseDate("2007-08-01").toString mustBe "2007-08-01T00:00:00.000+02:00"
      Rfc3339Util.parseDate("2007-05-08").toString mustBe "2007-05-08T00:00:00.000+02:00"
    }
    it("should write DateTime") {
      Rfc3339Util.writeDateTime(date) mustBe "2016-01-04T13:43:07.284000+0100"
    }
    it("should write Date") {
      Rfc3339Util.writeDate(date.toDateMidnight) mustBe "2016-01-04"
    }
  }
}
<commit_msg>#45: Fix timezone dependent unit tests<commit_after>package de.zalando.play.controllers

import org.joda.time.{DateTimeZone, DateTime}
import org.scalatest.{MustMatchers, FunSpec}

/**
  * @author slasch 
  * @since 04.01.2016.
  */
class Rfc3339UtilTest extends FunSpec with MustMatchers {

  val date = new DateTime(1451911387284L)

  val dtz = DateTimeZone.forID("GMT")

  describe("Rfc3339UtilTest") {

    it("should parse RFC3339 DateTime") {
      Rfc3339Util.parseDateTime("2007-05-01T15:43:26-07:00").withZone(dtz).toString mustBe "2007-05-01T22:43:26.000Z"
      Rfc3339Util.parseDateTime("2007-05-01T15:43:26.3-07:00").withZone(dtz).toString mustBe "2007-05-01T22:43:26.300Z"
      Rfc3339Util.parseDateTime("2007-05-01T15:43:26.3452-07:00").withZone(dtz).toString mustBe "2007-05-01T22:43:26.345Z"
      Rfc3339Util.parseDateTime("2007-05-01T15:43:26.3452Z").withZone(dtz).toString mustBe "2007-05-01T13:43:26.345Z"
      Rfc3339Util.parseDateTime("2007-05-01T15:43:26.3Z").withZone(dtz).toString mustBe "2007-05-01T13:43:26.300Z"
      Rfc3339Util.parseDateTime("2007-05-01T15:43:26Z").withZone(dtz).toString mustBe "2007-05-01T13:43:26.000Z"
    }
    it("should parse RFC3339 Date") {
      Rfc3339Util.parseDate("2007-05-01").withZoneRetainFields(dtz).toString mustBe "2007-05-01T00:00:00.000Z"
      Rfc3339Util.parseDate("2008-05-01").withZoneRetainFields(dtz).toString mustBe "2008-05-01T00:00:00.000Z"
      Rfc3339Util.parseDate("2007-08-01").withZoneRetainFields(dtz).toString mustBe "2007-08-01T00:00:00.000Z"
      Rfc3339Util.parseDate("2007-05-08").withZoneRetainFields(dtz).toString mustBe "2007-05-08T00:00:00.000Z"
    }
    it("should write DateTime") {
      Rfc3339Util.writeDateTime(date.withZone(dtz)) mustBe "2016-01-04T12:43:07.284000+0000"
    }
    it("should write Date") {
      Rfc3339Util.writeDate(date.toDateMidnight.withZoneRetainFields(dtz)) mustBe "2016-01-04"
    }
  }
}

{'fraction_non_alphanumeric': 0.15940815187046342, 'fraction_numerical': 0.24902289223897264, 'mean_word_length': 4.555038759689922, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3111481', 'n_tokens_mistral': 1980, 'n_tokens_neox': 1453, 'n_words': 153}