Search in sources :

Example 56 with DateTimeZone

use of org.joda.time.DateTimeZone in project SeriesGuide by UweTrottmann.

the class TimeToolsTest method test_parseEpisodeReleaseTime_Country.

@Test
public void test_parseEpisodeReleaseTime_Country() {
    // ensure a German show has its local release time correctly converted to UTC time
    // (we can be sure that in May there is always DST in effect in Europe/Berlin
    // so this test will likely not break if DST rules change)
    DateTimeZone showTimeZone = DateTimeZone.forID(EUROPE_BERLIN);
    String deviceTimeZone = AMERICA_LOS_ANGELES;
    long episodeReleaseTime = TimeTools.parseEpisodeReleaseDate(null, showTimeZone, "2013-05-31", // 20:00
    new LocalTime(20, 0), GERMANY, null, deviceTimeZone);
    System.out.println("Release time: " + episodeReleaseTime + " " + new Date(episodeReleaseTime));
    assertThat(episodeReleaseTime).isEqualTo(1370023200000L);
}
Also used : LocalTime(org.joda.time.LocalTime) DateTimeZone(org.joda.time.DateTimeZone) Date(java.util.Date) Test(org.junit.Test)

Example 57 with DateTimeZone

use of org.joda.time.DateTimeZone in project SeriesGuide by UweTrottmann.

the class TimeToolsTest method test_parseEpisodeReleaseTime.

@Test
public void test_parseEpisodeReleaseTime() {
    // ensure a US show has its local release time correctly converted to UTC time
    // (we can be sure that in May there is always DST in effect in America/New_York
    // so this test will likely not break if DST rules change)
    DateTimeZone showTimeZone = DateTimeZone.forID(AMERICA_NEW_YORK);
    String deviceTimeZone = AMERICA_LOS_ANGELES;
    long episodeReleaseTime = TimeTools.parseEpisodeReleaseDate(null, showTimeZone, "2013-05-31", // 20:00
    new LocalTime(20, 0), UNITED_STATES, null, deviceTimeZone);
    System.out.println("Release time: " + episodeReleaseTime + " " + new Date(episodeReleaseTime));
    assertThat(episodeReleaseTime).isEqualTo(1370055600000L);
}
Also used : LocalTime(org.joda.time.LocalTime) DateTimeZone(org.joda.time.DateTimeZone) Date(java.util.Date) Test(org.junit.Test)

Example 58 with DateTimeZone

use of org.joda.time.DateTimeZone in project SeriesGuide by UweTrottmann.

the class TimeToolsTest method test_parseEpisodeReleaseTime_NoHourPastMidnight.

@Test
public void test_parseEpisodeReleaseTime_NoHourPastMidnight() {
    // ensure episodes releasing in the hour past midnight are NOT moved to the next day
    // if it is a Netflix show
    DateTimeZone showTimeZone = DateTimeZone.forID(AMERICA_NEW_YORK);
    String deviceTimeZone = AMERICA_LOS_ANGELES;
    long episodeReleaseTime = TimeTools.parseEpisodeReleaseDate(null, showTimeZone, // +one day here
    "2013-06-01", // 00:35
    new LocalTime(0, 35), UNITED_STATES, "Netflix", deviceTimeZone);
    System.out.println("Release time: " + episodeReleaseTime + " " + new Date(episodeReleaseTime));
    assertThat(episodeReleaseTime).isEqualTo(1370072100000L);
}
Also used : LocalTime(org.joda.time.LocalTime) DateTimeZone(org.joda.time.DateTimeZone) Date(java.util.Date) Test(org.junit.Test)

Example 59 with DateTimeZone

use of org.joda.time.DateTimeZone in project SeriesGuide by UweTrottmann.

the class TimeToolsTest method test_parseEpisodeReleaseTime_HourPastMidnight.

@Test
public void test_parseEpisodeReleaseTime_HourPastMidnight() {
    // ensure episodes releasing in the hour past midnight are moved to the next day
    // e.g. if 00:35, the episode date is typically (wrongly) that of the previous day
    // this is common for late night shows, e.g. "Monday night" is technically "early Tuesday"
    DateTimeZone showTimeZone = DateTimeZone.forID(AMERICA_NEW_YORK);
    String deviceTimeZone = AMERICA_LOS_ANGELES;
    long episodeReleaseTime = TimeTools.parseEpisodeReleaseDate(null, showTimeZone, "2013-05-31", // 00:35
    new LocalTime(0, 35), UNITED_STATES, null, deviceTimeZone);
    System.out.println("Release time: " + episodeReleaseTime + " " + new Date(episodeReleaseTime));
    assertThat(episodeReleaseTime).isEqualTo(1370072100000L);
}
Also used : LocalTime(org.joda.time.LocalTime) DateTimeZone(org.joda.time.DateTimeZone) Date(java.util.Date) Test(org.junit.Test)

Example 60 with DateTimeZone

use of org.joda.time.DateTimeZone in project SeriesGuide by UweTrottmann.

the class TimeToolsTest method test_parseEpisodeReleaseTime_Country.

@Test
public void test_parseEpisodeReleaseTime_Country() {
    // ensure a German show has its local release time correctly converted to UTC time
    // (we can be sure that in May there is always DST in effect in Europe/Berlin
    // so this test will likely not break if DST rules change)
    DateTimeZone showTimeZone = DateTimeZone.forID(EUROPE_BERLIN);
    String deviceTimeZone = AMERICA_LOS_ANGELES;
    long episodeReleaseTime = TimeTools.parseEpisodeReleaseDate(null, showTimeZone, "2013-05-31", // 20:00
    new LocalTime(20, 0), GERMANY, null, deviceTimeZone);
    System.out.println("Release time: " + episodeReleaseTime + " " + new Date(episodeReleaseTime));
    assertThat(episodeReleaseTime).isEqualTo(1370023200000L);
}
Also used : LocalTime(org.joda.time.LocalTime) DateTimeZone(org.joda.time.DateTimeZone) Date(java.util.Date) Test(org.junit.Test)

Aggregations

DateTimeZone (org.joda.time.DateTimeZone)263 DateTime (org.joda.time.DateTime)123 ArrayList (java.util.ArrayList)36 Test (org.testng.annotations.Test)35 LocalDate (org.joda.time.LocalDate)27 Test (org.junit.Test)21 TimeIntervalRounding (org.elasticsearch.common.rounding.Rounding.TimeIntervalRounding)18 TimeUnitRounding (org.elasticsearch.common.rounding.Rounding.TimeUnitRounding)18 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)17 IOException (java.io.IOException)16 HashMap (java.util.HashMap)15 UUID (java.util.UUID)14 TimeFormat (org.gephi.graph.api.TimeFormat)13 MetricExpression (com.linkedin.thirdeye.client.MetricExpression)12 Date (java.util.Date)12 Chronology (org.joda.time.Chronology)12 LocalDateTime (org.joda.time.LocalDateTime)12 DefaultBlockingState (org.killbill.billing.junction.DefaultBlockingState)11 LocalTime (org.joda.time.LocalTime)10 SubscriptionBaseTransition (org.killbill.billing.subscription.api.user.SubscriptionBaseTransition)10