Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date filter #11

Closed
wants to merge 3 commits into from
Closed

Date filter #11

wants to merge 3 commits into from

Conversation

maria-p
Copy link

@maria-p maria-p commented Jan 26, 2012

Adds date filter to twig.js. It is not fully implemented and doesn't support all php date formatting symbols, but I still think it may be useful to have at least some of the formatting possibilities.

I'm also not sure about twig.js and twig.dev.js - it was generated be compile.php script and it seems to rewrite all the files, not just filter connected parts.

@schmittjoh
Copy link
Owner

Did you check the Closure Library for their date formatting support? I'd like to limit the code that we have to maintain ourselves wherever possible.

@maria-p
Copy link
Author

maria-p commented Jan 27, 2012

Checked it just now, and it seems that it implements only native js Date object methods, that still doesn't help to format date inside the template

@sstok
Copy link

sstok commented Apr 9, 2012

Is http://momentjs.com/ is not an option?

@schmittjoh
Copy link
Owner

Depends on how compatible it is with PHP, but it looks pretty big (half the size of the entire library). So, maybe as a separate file that can be included on demand only.

The reason why I haven't merged this yet is that there are some tests for which this patch is failing, and that it is depending on the browser for parsing (inconsistent). If someone wants to take a stab, please select the date-related tests from https://github.com/fabpot/Twig/tree/master/test/Twig/Tests/Fixtures, and add their names in this file: https://github.com/schmittjoh/twig.js/blob/master/bin/generate_test_templates.php#L45

@patie
Copy link

patie commented Aug 11, 2013

something new ?

@lughino
Copy link

lughino commented Aug 24, 2013

I associate myself!
This project is extremely powerful! Too bad it is not supported by many people ..

@henrycatalinismith
Copy link
Contributor

The date function is a question of user expectation management. A function with this name will create the expectation of compatibility with Twig's date function which is powered by PHP's extremely feature-rich built-in date function. Better to omit the function completely, and let people fulfill their own specific date-related use cases with custom functions.

I'm not 100% opposed to the idea though. If anybody out there has the time for this task, I'd welcome a high quality pull request with open arms. It'd be a lot of code though, and we'd need an even larger quantity of automated tests for it. It's a big job.

Let's close this issue for now.

@ryanotella
Copy link

@hnrysmth Would this be an option? http://phpjs.org/functions/date/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants