Search in sources :

Example 1 with LocalTime

use of org.joda.time.LocalTime 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 2 with LocalTime

use of org.joda.time.LocalTime 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 3 with LocalTime

use of org.joda.time.LocalTime 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 4 with LocalTime

use of org.joda.time.LocalTime 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 5 with LocalTime

use of org.joda.time.LocalTime 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

LocalTime (org.joda.time.LocalTime)81 Test (org.junit.Test)39 OpeningHours (io.jawg.osmcontributor.model.utils.OpeningHours)17 LocalDate (org.joda.time.LocalDate)14 DateTime (org.joda.time.DateTime)13 LocalDateTime (org.joda.time.LocalDateTime)13 Date (java.util.Date)11 DateTimeZone (org.joda.time.DateTimeZone)10 OpeningMonth (io.jawg.osmcontributor.model.utils.OpeningMonth)6 Test (org.testng.annotations.Test)6 ArrayList (java.util.ArrayList)5 OpeningTime (io.jawg.osmcontributor.model.utils.OpeningTime)4 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)3 ContentValues (android.content.ContentValues)2 Time (java.sql.Time)2 EntityManager (javax.persistence.EntityManager)2 EntityTransaction (javax.persistence.EntityTransaction)2 JodaSample3 (org.datanucleus.samples.types.jodatime.JodaSample3)2 DatePickerDialog (android.app.DatePickerDialog)1 TimePickerDialog (android.app.TimePickerDialog)1