Giter Club home page Giter Club logo

jchronic's People

Contributors

brianm avatar dependabot[bot] avatar ewanmellor avatar samtingleff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jchronic's Issues

Anchors do not honour timezone

When parsing "last sunday", with the default timezone set to UTC+1 and options.now set to UTC, the resulting date is Sun 10AM UTC+1, not Sun 12AM UTC as I would expect (since now is UTC). The issue stems from Time.java, which doesn't copy the timezone:

  public static Calendar y(Calendar basis) {
    Calendar clone = Calendar.getInstance();
    clone.clear();
    clone.set(Calendar.YEAR, basis.get(Calendar.YEAR));
    return clone;
  }

Parser test failing

Running: mvn test

On: 0.2.7-SNAPSHOT

Failed tests:   test_parse_guess_o_r_g_r(com.mdimension.jchronic.ParserTest): expected:Fri Mar 16 12:30:00 GMT 2007 but was:Fri Mar 16 11:30:00 GMT 2007
-------------------------------------------------------------------------------
Test set: com.mdimension.jchronic.ParserTest
-------------------------------------------------------------------------------
Tests run: 18, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.118 sec
test_parse_guess_o_r_g_r(com.mdimension.jchronic.ParserTest)  Time elapsed: 0.006 sec  
junit.framework.AssertionFailedError: expected:Fri Mar 16 12:30:00 GMT 2007 but was:Fri Mar 16 11:30:00 GMT 2007
    at junit.framework.Assert.fail(Assert.java:47)
    at junit.framework.Assert.failNotEquals(Assert.java:283)
    at junit.framework.Assert.assertEquals(Assert.java:64)
    at junit.framework.Assert.assertEquals(Assert.java:71)
    at com.mdimension.jchronic.ParserTest.assertEquals(ParserTest.java:26)
    at com.mdimension.jchronic.ParserTest.assertEquals(ParserTest.java:22)
    at com.mdimension.jchronic.ParserTest.test_parse_guess_o_r_g_r(ParserTest.java:598)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at junit.framework.TestCase.runTest(TestCase.java:168)
    at junit.framework.TestCase.runBare(TestCase.java:134)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:232)
    at junit.framework.TestSuite.run(TestSuite.java:227)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
    at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
    at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
    at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)

When using Past pointer option, JChronic parses date+time to the wrong date.

Here is an example. "2014-03-10 19:00" actually parses as 2014-03-09 19:00.

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;

import org.junit.Test;

import com.mdimension.jchronic.Chronic;
import com.mdimension.jchronic.Options;
import com.mdimension.jchronic.tags.Pointer;
import com.mdimension.jchronic.utils.Span;

public class PenDownloadTest {
    @Test public void testJchronicPast() {
        TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles");
        assertTrue(zone.observesDaylightTime());
        Locale locale = Locale.US;
        Calendar now = Calendar.getInstance(zone, locale);
        now.clear();
        now.set(2014, Calendar.MARCH, 13, 0, 0, 0);
        Options options = new Options(Pointer.PointerType.PAST, now, false, 6);
        Calendar expectedTime = Calendar.getInstance(zone, locale);
        expectedTime.clear();
        expectedTime.set(2014, Calendar.MARCH, 10, 19, 0);
        Span expectedSpan = new Span(expectedTime, Calendar.SECOND, 1);
        Span actualSpan = Chronic.parse("2014-03-10 19:00", options);
        assertEquals(expectedSpan, actualSpan);
    }

}

Negative timezones aren't supported

Using the code

 Span d = Chronic.parse(date); 

With date referring to the examples below.

This doesn't parse (the variable d above returns null):

 2012-11-18 12:44:11 -0500

It seems the negative timezone is making the library fail.

When you remove "-0500" it does parse.

Can we please support negative timezones?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.