├── .editorconfig ├── .ember-cli ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .jshintrc ├── .npmignore ├── .template-lintrc.js ├── .travis.yml ├── .watchmanconfig ├── LICENSE.md ├── README.md ├── addon ├── .eslintrc.js ├── .gitkeep └── helpers │ ├── date-format.js │ └── date-from-now.js ├── app ├── .eslintrc.js ├── .gitkeep └── helpers │ ├── date-format.js │ └── date-from-now.js ├── blueprints └── ember-date-fns │ └── index.js ├── circle.yml ├── config ├── ember-try.js └── environment.js ├── ember-cli-build.js ├── index.js ├── package.json ├── testem.js ├── tests ├── .eslintrc.js ├── dummy │ ├── app │ │ ├── app.js │ │ ├── components │ │ │ └── .gitkeep │ │ ├── controllers │ │ │ ├── .gitkeep │ │ │ └── application.js │ │ ├── helpers │ │ │ └── .gitkeep │ │ ├── index.html │ │ ├── models │ │ │ └── .gitkeep │ │ ├── resolver.js │ │ ├── router.js │ │ ├── routes │ │ │ └── .gitkeep │ │ ├── styles │ │ │ └── app.css │ │ └── templates │ │ │ ├── application.hbs │ │ │ └── components │ │ │ └── .gitkeep │ ├── config │ │ ├── environment.js │ │ ├── optional-features.json │ │ └── targets.js │ └── public │ │ ├── crossdomain.xml │ │ └── robots.txt ├── helpers │ ├── destroy-app.js │ ├── module-for-acceptance.js │ ├── resolver.js │ └── start-app.js ├── index.html ├── integration │ └── .gitkeep ├── test-helper.js └── unit │ ├── .gitkeep │ └── helpers │ ├── date-format-test.js │ └── date-from-now-test.js ├── vendor └── .gitkeep └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.hbs] 17 | insert_final_newline = false 18 | 19 | [*.{diff,md}] 20 | trim_trailing_whitespace = false 21 | -------------------------------------------------------------------------------- /.ember-cli: -------------------------------------------------------------------------------- 1 | { 2 | /** 3 | Ember CLI sends analytics information by default. The data is completely 4 | anonymous, but there are times when you might want to disable this behavior. 5 | 6 | Setting `disableAnalytics` to true will prevent any data from being sent. 7 | */ 8 | "disableAnalytics": false 9 | } 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # unconventional js 2 | /blueprints/*/files/ 3 | /vendor/ 4 | 5 | # compiled output 6 | /dist/ 7 | /tmp/ 8 | 9 | # dependencies 10 | /bower_components/ 11 | /node_modules/ 12 | 13 | # misc 14 | /coverage/ 15 | !.* 16 | 17 | # ember-try 18 | /.node_modules.ember-try/ 19 | /bower.json.ember-try 20 | /package.json.ember-try 21 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parserOptions: { 4 | ecmaVersion: 2017, 5 | sourceType: 'module' 6 | }, 7 | plugins: [ 8 | 'ember' 9 | ], 10 | extends: [ 11 | 'eslint:recommended', 12 | 'plugin:ember/recommended' 13 | ], 14 | env: { 15 | browser: true 16 | }, 17 | rules: { 18 | }, 19 | overrides: [ 20 | // node files 21 | { 22 | files: [ 23 | '.eslintrc.js', 24 | '.template-lintrc.js', 25 | 'ember-cli-build.js', 26 | 'index.js', 27 | 'testem.js', 28 | 'blueprints/*/index.js', 29 | 'config/**/*.js', 30 | 'tests/dummy/config/**/*.js' 31 | ], 32 | excludedFiles: [ 33 | 'addon/**', 34 | 'addon-test-support/**', 35 | 'app/**', 36 | 'tests/dummy/app/**' 37 | ], 38 | parserOptions: { 39 | sourceType: 'script', 40 | ecmaVersion: 2015 41 | }, 42 | env: { 43 | browser: false, 44 | node: true 45 | }, 46 | plugins: ['node'], 47 | rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, { 48 | // add your custom rules and overrides for node files here 49 | }) 50 | } 51 | ] 52 | }; 53 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist/ 5 | /tmp/ 6 | 7 | # dependencies 8 | /bower_components/ 9 | /node_modules/ 10 | 11 | # misc 12 | /.env* 13 | /.sass-cache 14 | /connect.lock 15 | /coverage/ 16 | /libpeerconnection.log 17 | /npm-debug.log* 18 | /testem.log 19 | /yarn-error.log 20 | 21 | # ember-try 22 | /.node_modules.ember-try/ 23 | /bower.json.ember-try 24 | /package.json.ember-try 25 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "predef": [ 3 | "document", 4 | "window", 5 | "-Promise" 6 | ], 7 | "browser": true, 8 | "boss": true, 9 | "curly": true, 10 | "debug": false, 11 | "devel": true, 12 | "eqeqeq": true, 13 | "evil": true, 14 | "forin": false, 15 | "immed": false, 16 | "laxbreak": false, 17 | "newcap": true, 18 | "noarg": true, 19 | "noempty": false, 20 | "nonew": false, 21 | "nomen": false, 22 | "onevar": false, 23 | "plusplus": false, 24 | "regexp": false, 25 | "undef": true, 26 | "sub": true, 27 | "strict": false, 28 | "white": false, 29 | "eqnull": true, 30 | "esversion": 6, 31 | "unused": true 32 | } 33 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist/ 3 | /tmp/ 4 | 5 | # dependencies 6 | /bower_components/ 7 | 8 | # misc 9 | /.bowerrc 10 | /.editorconfig 11 | /.ember-cli 12 | /.env* 13 | /.eslintignore 14 | /.eslintrc.js 15 | /.gitignore 16 | /.template-lintrc.js 17 | /.travis.yml 18 | /.watchmanconfig 19 | /bower.json 20 | /config/ember-try.js 21 | /CONTRIBUTING.md 22 | /ember-cli-build.js 23 | /testem.js 24 | /tests/ 25 | /yarn.lock 26 | .gitkeep 27 | 28 | # ember-try 29 | /.node_modules.ember-try/ 30 | /bower.json.ember-try 31 | /package.json.ember-try 32 | -------------------------------------------------------------------------------- /.template-lintrc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: 'recommended' 5 | }; 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: node_js 3 | node_js: 4 | # we recommend testing addons with the same minimum supported node version as Ember CLI 5 | # so that your addon works for all apps 6 | - "6" 7 | 8 | sudo: false 9 | dist: trusty 10 | 11 | addons: 12 | chrome: stable 13 | 14 | cache: 15 | yarn: true 16 | 17 | env: 18 | global: 19 | # See https://git.io/vdao3 for details. 20 | - JOBS=1 21 | 22 | branches: 23 | only: 24 | - master 25 | # npm version tags 26 | - /^v\d+\.\d+\.\d+/ 27 | 28 | jobs: 29 | fail_fast: true 30 | allow_failures: 31 | - env: EMBER_TRY_SCENARIO=ember-canary 32 | 33 | include: 34 | # runs linting and tests with current locked deps 35 | 36 | - stage: "Tests" 37 | name: "Tests" 38 | install: 39 | - yarn install --non-interactive 40 | script: 41 | - yarn lint:js 42 | - yarn test 43 | 44 | - name: "Floating Dependencies" 45 | script: 46 | - yarn test 47 | 48 | # we recommend new addons test the current and previous LTS 49 | # as well as latest stable release (bonus points to beta/canary) 50 | - stage: "Additional Tests" 51 | env: EMBER_TRY_SCENARIO=ember-lts-2.18 52 | - env: EMBER_TRY_SCENARIO=ember-lts-3.4 53 | - env: EMBER_TRY_SCENARIO=ember-release 54 | - env: EMBER_TRY_SCENARIO=ember-beta 55 | - env: EMBER_TRY_SCENARIO=ember-canary 56 | - env: EMBER_TRY_SCENARIO=ember-default-with-jquery 57 | 58 | before_install: 59 | - curl -o- -L https://yarnpkg.com/install.sh | bash 60 | - export PATH=$HOME/.yarn/bin:$PATH 61 | 62 | install: 63 | - yarn install --no-lockfile --non-interactive 64 | 65 | script: 66 | - node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO 67 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": ["tmp", "dist"] 3 | } 4 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ember date-fns 2 | 3 | [![npm version](https://badge.fury.io/js/ember-date-fns.svg)](https://badge.fury.io/js/ember-date-fns) 4 | [![CircleCI](https://circleci.com/gh/oskarrough/ember-date-fns.svg?style=svg)](https://circleci.com/gh/oskarrough/ember-date-fns) 5 | 6 | Lightweight date helpers for your ember-cli application thanks to [date-fns](https://date-fns.org/). If all you need is to format a date, Ember date-fns will help you. 7 | 8 | If you are looking for more features, see [ember-moment](https://github.com/stefanpenner/ember-moment) instead. 9 | 10 | ## Installation 11 | 12 | In your ember-cli project, run either 13 | 14 | `ember install ember-date-fns` 15 | 16 | or 17 | 18 | `yarn add ember-date-fns` 19 | 20 | or 21 | 22 | `npm install --save ember-date-fns` 23 | 24 | 25 | ## Available helpers 26 | 27 | All helpers map to the date-fns function of the same name. 28 | 29 | + [`date-format`](#date-format) 30 | + [`date-from-now`](#date-from-now) 31 | 32 | ## Usage 33 | 34 | ### `date-format` 35 | 36 | Uses [format](https://date-fns.org/docs/format) to format a date object, string or timestamp. 37 | 38 | ```hbs 39 | {{date-format date "D. MMM YYYY"}} 40 | ``` 41 | 42 | ### `date-from-now` 43 | 44 | Uses [distanceInWordsToNow](https://date-fns.org/docs/distanceInWordsToNow) to return "time ago". By default no suffix is added. 45 | 46 | ```hbs 47 | {{date-from-now date addSuffix=true}} 48 | ``` 49 | 50 | ### Exposing additional date-fns 51 | 52 | `date-fns` provides many functions for manipulating dates. In order to reduce bundle size only `date-fns/distance_in_words_to_now` and `date-fns/format` helpers are included by default. However you can import any functions anywhere in your application. 53 | 54 | Example: 55 | 56 | ```javascript 57 | // app/components/some-component.js 58 | 59 | import Ember from 'ember'; 60 | import endOfDay from 'date-fns/end_of_day'; 61 | 62 | // Your component code here... 63 | ``` 64 | -------------------------------------------------------------------------------- /addon/.eslintrc.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 3 | module.exports = { 4 | env: { 5 | browser: true, 6 | node: false, 7 | }, 8 | rules: { 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /addon/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oskarrough/ember-date-fns/00ba5630f0ccdff2cfac11f1f9c76a687e7fced6/addon/.gitkeep -------------------------------------------------------------------------------- /addon/helpers/date-format.js: -------------------------------------------------------------------------------- 1 | import { helper } from '@ember/component/helper'; 2 | import formatDate from 'date-fns/format'; 3 | 4 | /** 5 | Return the formatted date string in the given format. 6 | @method dateFormat 7 | @static 8 | @for date-fns/date-format 9 | @param {Date|String|Number} date the original date 10 | @param {String} format the string of tokens 11 | @return {String} the formatted date string 12 | @public 13 | */ 14 | export function dateFormat([date, format]) { 15 | return formatDate(date, format); 16 | } 17 | 18 | export default helper(dateFormat); 19 | -------------------------------------------------------------------------------- /addon/helpers/date-from-now.js: -------------------------------------------------------------------------------- 1 | import { helper } from '@ember/component/helper'; 2 | import distanceInWordsToNow from 'date-fns/distance_in_words_to_now'; 3 | 4 | /** 5 | Return the distance between the given date and now in words. 6 | @method dateFromNow 7 | @static 8 | @for date-fns/date-fom-now 9 | @param {Date|String|Number} date the given date 10 | @param {Object} options the object with options 11 | @return {String} the distance in words 12 | @public 13 | */ 14 | export function dateFromNow([date], options = {}) { 15 | return distanceInWordsToNow(date, options); 16 | } 17 | 18 | export default helper(dateFromNow); 19 | -------------------------------------------------------------------------------- /app/.eslintrc.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 3 | module.exports = { 4 | env: { 5 | browser: true, 6 | node: false, 7 | }, 8 | rules: { 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /app/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oskarrough/ember-date-fns/00ba5630f0ccdff2cfac11f1f9c76a687e7fced6/app/.gitkeep -------------------------------------------------------------------------------- /app/helpers/date-format.js: -------------------------------------------------------------------------------- 1 | export { default, dateFormat } from 'ember-date-fns/helpers/date-format'; 2 | -------------------------------------------------------------------------------- /app/helpers/date-from-now.js: -------------------------------------------------------------------------------- 1 | export { default, dateFromNow } from 'ember-date-fns/helpers/date-from-now'; 2 | -------------------------------------------------------------------------------- /blueprints/ember-date-fns/index.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 3 | module.exports = { 4 | description: 'Add `date-fns` to the consumer application', 5 | 6 | afterInstall() { 7 | return this.addPackagesToProject([ 8 | { name: 'date-fns', target: '^1.30.1' }, 9 | ]); 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | environment: 3 | PATH: "${PATH}:${HOME}/.yarn/bin:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin" 4 | pre: 5 | - mkdir ~/.yarn-cache 6 | node: 7 | version: "stable" 8 | 9 | dependencies: 10 | pre: 11 | - | 12 | if [[ ! -e ~/.yarn/bin/yarn ]]; then 13 | curl -o- -L https://yarnpkg.com/install.sh | bash 14 | fi 15 | cache_directories: 16 | - ~/.yarn 17 | - ~/.yarn-cache 18 | override: 19 | - yarn 20 | 21 | test: 22 | override: 23 | - yarn test 24 | -------------------------------------------------------------------------------- /config/ember-try.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const getChannelURL = require('ember-source-channel-url'); 4 | 5 | module.exports = function() { 6 | return Promise.all([ 7 | getChannelURL('release'), 8 | getChannelURL('beta'), 9 | getChannelURL('canary') 10 | ]).then((urls) => { 11 | return { 12 | useYarn: true, 13 | scenarios: [ 14 | { 15 | name: 'ember-lts-2.18', 16 | env: { 17 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 'jquery-integration': true }) 18 | }, 19 | npm: { 20 | devDependencies: { 21 | '@ember/jquery': '^0.5.1', 22 | 'ember-source': '~2.18.0' 23 | } 24 | } 25 | }, 26 | { 27 | name: 'ember-lts-3.4', 28 | npm: { 29 | devDependencies: { 30 | 'ember-source': '~3.4.0' 31 | } 32 | } 33 | }, 34 | { 35 | name: 'ember-release', 36 | npm: { 37 | devDependencies: { 38 | 'ember-source': urls[0] 39 | } 40 | } 41 | }, 42 | { 43 | name: 'ember-beta', 44 | npm: { 45 | devDependencies: { 46 | 'ember-source': urls[1] 47 | } 48 | } 49 | }, 50 | { 51 | name: 'ember-canary', 52 | npm: { 53 | devDependencies: { 54 | 'ember-source': urls[2] 55 | } 56 | } 57 | }, 58 | // The default `.travis.yml` runs this scenario via `yarn test`, 59 | // not via `ember try`. It's still included here so that running 60 | // `ember try:each` manually or from a customized CI config will run it 61 | // along with all the other scenarios. 62 | { 63 | name: 'ember-default', 64 | npm: { 65 | devDependencies: {} 66 | } 67 | }, 68 | { 69 | name: 'ember-default-with-jquery', 70 | env: { 71 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 72 | 'jquery-integration': true 73 | }) 74 | }, 75 | npm: { 76 | devDependencies: { 77 | '@ember/jquery': '^0.5.1' 78 | } 79 | } 80 | } 81 | ] 82 | }; 83 | }); 84 | }; 85 | -------------------------------------------------------------------------------- /config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(/* environment, appConfig */) { 4 | return { }; 5 | }; 6 | -------------------------------------------------------------------------------- /ember-cli-build.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); 4 | 5 | module.exports = function(defaults) { 6 | let app = new EmberAddon(defaults, { 7 | // Add options here 8 | }); 9 | 10 | /* 11 | This build file specifies the options for the dummy test app of this 12 | addon, located in `/tests/dummy` 13 | This build file does *not* influence how the addon or the app using it 14 | behave. You most likely want to be modifying `./index.js` or app's build file 15 | */ 16 | 17 | return app.toTree(); 18 | }; 19 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | name: require('./package').name, 5 | 6 | options: { 7 | autoImport: { 8 | exclude: [] 9 | } 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-date-fns", 3 | "version": "0.5.0", 4 | "description": "Date helpers for Ember.js using date-fns", 5 | "keywords": [ 6 | "date", 7 | "date-fns", 8 | "ember-addon", 9 | "ember-date", 10 | "moment", 11 | "momentjs" 12 | ], 13 | "license": "MIT", 14 | "author": { 15 | "name": "Oskar Rough", 16 | "email": "oskar@rough.dk", 17 | "url": "https://github.com/oskarrough" 18 | }, 19 | "contributors": [ 20 | { 21 | "name": "Laurin Quast", 22 | "email": "laurinquast@googlemail.com", 23 | "url": "https://github.com/n1ru4l" 24 | } 25 | ], 26 | "directories": { 27 | "test": "tests" 28 | }, 29 | "repository": "https://github.com/oskarrough/ember-date-fns.git", 30 | "scripts": { 31 | "build": "ember build", 32 | "lint:js": "eslint .", 33 | "start": "ember serve", 34 | "test": "ember test", 35 | "test:all": "ember try:each" 36 | }, 37 | "dependencies": { 38 | "date-fns": "^1.30.1", 39 | "ember-auto-import": "^1.2.19", 40 | "ember-cli-babel": "^7.4.1" 41 | }, 42 | "devDependencies": { 43 | "broccoli-asset-rev": "^3.0.0", 44 | "ember-cli": "~3.7.1", 45 | "ember-cli-app-version": "^3.2.0", 46 | "ember-cli-dependency-checker": "3.1.0", 47 | "ember-cli-eslint": "^5.1.0", 48 | "ember-cli-htmlbars": "^3.0.1", 49 | "ember-cli-htmlbars-inline-precompile": "^2.1.0", 50 | "ember-cli-inject-live-reload": "^2.0.1", 51 | "ember-cli-qunit": "^4.4.0", 52 | "ember-disable-prototype-extensions": "1.1.3", 53 | "ember-export-application-global": "^2.0.0", 54 | "ember-load-initializers": "^2.0.0", 55 | "ember-maybe-import-regenerator": "^0.1.6", 56 | "ember-resolver": "^5.0.1", 57 | "ember-source": "~3.7.2", 58 | "ember-source-channel-url": "^1.1.0", 59 | "ember-try": "^1.1.0", 60 | "eslint-plugin-ember": "^6.2.0", 61 | "eslint-plugin-node": "^8.0.1", 62 | "loader.js": "^4.7.0" 63 | }, 64 | "engines": { 65 | "node": "6.* || 8.* || >= 10.*" 66 | }, 67 | "ember-addon": { 68 | "configPath": "tests/dummy/config" 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /testem.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | test_page: 'tests/index.html?hidepassed', 3 | disable_watching: true, 4 | launch_in_ci: [ 5 | 'Chrome' 6 | ], 7 | launch_in_dev: [ 8 | 'Chrome' 9 | ], 10 | browser_args: { 11 | Chrome: { 12 | ci: [ 13 | // --no-sandbox is needed when running Chrome inside a container 14 | process.env.CI ? '--no-sandbox' : null, 15 | '--headless', 16 | '--disable-gpu', 17 | '--disable-dev-shm-usage', 18 | '--disable-software-rasterizer', 19 | '--mute-audio', 20 | '--remote-debugging-port=0', 21 | '--window-size=1440,900' 22 | ].filter(Boolean) 23 | } 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /tests/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | embertest: true 4 | } 5 | }; 6 | -------------------------------------------------------------------------------- /tests/dummy/app/app.js: -------------------------------------------------------------------------------- 1 | import Application from '@ember/application'; 2 | import Resolver from './resolver'; 3 | import loadInitializers from 'ember-load-initializers'; 4 | import config from './config/environment'; 5 | 6 | const App = Application.extend({ 7 | modulePrefix: config.modulePrefix, 8 | podModulePrefix: config.podModulePrefix, 9 | Resolver 10 | }); 11 | 12 | loadInitializers(App, config.modulePrefix); 13 | 14 | export default App; 15 | -------------------------------------------------------------------------------- /tests/dummy/app/components/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oskarrough/ember-date-fns/00ba5630f0ccdff2cfac11f1f9c76a687e7fced6/tests/dummy/app/components/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/controllers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oskarrough/ember-date-fns/00ba5630f0ccdff2cfac11f1f9c76a687e7fced6/tests/dummy/app/controllers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/controllers/application.js: -------------------------------------------------------------------------------- 1 | import Controller from '@ember/controller'; 2 | import { computed } from '@ember/object'; 3 | import getISOYear from 'date-fns/get_iso_year'; 4 | 5 | export default Controller.extend({ 6 | today: computed(function () { 7 | return new Date(); 8 | }), 9 | 10 | lastChristmas: computed(function () { 11 | return new Date('2016-12-24'); 12 | }), 13 | 14 | year: computed(function() { 15 | return getISOYear(new Date()); 16 | }) 17 | }); 18 | -------------------------------------------------------------------------------- /tests/dummy/app/helpers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oskarrough/ember-date-fns/00ba5630f0ccdff2cfac11f1f9c76a687e7fced6/tests/dummy/app/helpers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Ember date-fns 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | 12 | 13 | 14 | 15 | {{content-for "head-footer"}} 16 | 17 | 18 | {{content-for "body"}} 19 | 20 | 21 | 22 | 23 | {{content-for "body-footer"}} 24 | 25 | 26 | -------------------------------------------------------------------------------- /tests/dummy/app/models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oskarrough/ember-date-fns/00ba5630f0ccdff2cfac11f1f9c76a687e7fced6/tests/dummy/app/models/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from 'ember-resolver'; 2 | 3 | export default Resolver; 4 | -------------------------------------------------------------------------------- /tests/dummy/app/router.js: -------------------------------------------------------------------------------- 1 | import EmberRouter from '@ember/routing/router'; 2 | import config from './config/environment'; 3 | 4 | const Router = EmberRouter.extend({ 5 | location: config.locationType, 6 | rootURL: config.rootURL 7 | }); 8 | 9 | Router.map(function() { 10 | }); 11 | 12 | export default Router; 13 | -------------------------------------------------------------------------------- /tests/dummy/app/routes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oskarrough/ember-date-fns/00ba5630f0ccdff2cfac11f1f9c76a687e7fced6/tests/dummy/app/routes/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/styles/app.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; 3 | font-size: 16px; 4 | line-height: 1.4; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/application.hbs: -------------------------------------------------------------------------------- 1 |

Ember date-fns

2 |

This is a demonstration of the ember-date-fns addon.

3 | 4 |
5 | 6 |

date-format

7 | {{today}}
8 | {{date-format today}} 9 | 10 |

date-from-now

11 | Christmas 2016 was...
12 | {{date-from-now lastChristmas}}
13 | {{date-from-now lastChristmas addSuffix=true}} 14 | 15 |

Current year

16 | {{year}} 17 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/components/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oskarrough/ember-date-fns/00ba5630f0ccdff2cfac11f1f9c76a687e7fced6/tests/dummy/app/templates/components/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(environment) { 4 | let ENV = { 5 | modulePrefix: 'dummy', 6 | environment, 7 | rootURL: '/', 8 | locationType: 'auto', 9 | EmberENV: { 10 | FEATURES: { 11 | // Here you can enable experimental features on an ember canary build 12 | // e.g. 'with-controller': true 13 | }, 14 | EXTEND_PROTOTYPES: { 15 | // Prevent Ember Data from overriding Date.parse. 16 | Date: false 17 | } 18 | }, 19 | 20 | APP: { 21 | // Here you can pass flags/options to your application instance 22 | // when it is created 23 | } 24 | }; 25 | 26 | if (environment === 'development') { 27 | // ENV.APP.LOG_RESOLVER = true; 28 | // ENV.APP.LOG_ACTIVE_GENERATION = true; 29 | // ENV.APP.LOG_TRANSITIONS = true; 30 | // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; 31 | // ENV.APP.LOG_VIEW_LOOKUPS = true; 32 | } 33 | 34 | if (environment === 'test') { 35 | // Testem prefers this... 36 | ENV.locationType = 'none'; 37 | 38 | // keep test console output quieter 39 | ENV.APP.LOG_ACTIVE_GENERATION = false; 40 | ENV.APP.LOG_VIEW_LOOKUPS = false; 41 | 42 | ENV.APP.rootElement = '#ember-testing'; 43 | ENV.APP.autoboot = false; 44 | } 45 | 46 | if (environment === 'production') { 47 | // here you can enable a production-specific feature 48 | } 49 | 50 | return ENV; 51 | }; 52 | -------------------------------------------------------------------------------- /tests/dummy/config/optional-features.json: -------------------------------------------------------------------------------- 1 | { 2 | "jquery-integration": false 3 | } 4 | -------------------------------------------------------------------------------- /tests/dummy/config/targets.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const browsers = [ 4 | 'last 1 Chrome versions', 5 | 'last 1 Firefox versions', 6 | 'last 1 Safari versions' 7 | ]; 8 | 9 | const isCI = !!process.env.CI; 10 | const isProduction = process.env.EMBER_ENV === 'production'; 11 | 12 | if (isCI || isProduction) { 13 | browsers.push('ie 11'); 14 | } 15 | 16 | module.exports = { 17 | browsers 18 | }; 19 | -------------------------------------------------------------------------------- /tests/dummy/public/crossdomain.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /tests/dummy/public/robots.txt: -------------------------------------------------------------------------------- 1 | # http://www.robotstxt.org 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /tests/helpers/destroy-app.js: -------------------------------------------------------------------------------- 1 | import { run } from '@ember/runloop'; 2 | 3 | export default function destroyApp(application) { 4 | run(application, 'destroy'); 5 | } 6 | -------------------------------------------------------------------------------- /tests/helpers/module-for-acceptance.js: -------------------------------------------------------------------------------- 1 | import { module } from 'qunit'; 2 | import { Promise } from 'rsvp'; 3 | import startApp from '../helpers/start-app'; 4 | import destroyApp from '../helpers/destroy-app'; 5 | 6 | export default function(name, options = {}) { 7 | module(name, { 8 | beforeEach() { 9 | this.application = startApp(); 10 | 11 | if (options.beforeEach) { 12 | return options.beforeEach.apply(this, arguments); 13 | } 14 | }, 15 | 16 | afterEach() { 17 | let afterEach = options.afterEach && options.afterEach.apply(this, arguments); 18 | return Promise.resolve(afterEach).then(() => destroyApp(this.application)); 19 | } 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /tests/helpers/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from '../../resolver'; 2 | import config from '../../config/environment'; 3 | 4 | const resolver = Resolver.create(); 5 | 6 | resolver.namespace = { 7 | modulePrefix: config.modulePrefix, 8 | podModulePrefix: config.podModulePrefix 9 | }; 10 | 11 | export default resolver; 12 | -------------------------------------------------------------------------------- /tests/helpers/start-app.js: -------------------------------------------------------------------------------- 1 | import { assign } from '@ember/polyfills'; 2 | import { run } from '@ember/runloop'; 3 | import Application from '../../app'; 4 | import config from '../../config/environment'; 5 | 6 | export default function startApp(attrs) { 7 | let application; 8 | 9 | // use defaults, but you can override 10 | let attributes = assign({}, config.APP, attrs); 11 | 12 | run(() => { 13 | application = Application.create(attributes); 14 | application.setupForTesting(); 15 | application.injectTestHelpers(); 16 | }); 17 | 18 | return application; 19 | } 20 | -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy Tests 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | {{content-for "test-head"}} 12 | 13 | 14 | 15 | 16 | 17 | {{content-for "head-footer"}} 18 | {{content-for "test-head-footer"}} 19 | 20 | 21 | {{content-for "body"}} 22 | {{content-for "test-body"}} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | {{content-for "body-footer"}} 31 | {{content-for "test-body-footer"}} 32 | 33 | 34 | -------------------------------------------------------------------------------- /tests/integration/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oskarrough/ember-date-fns/00ba5630f0ccdff2cfac11f1f9c76a687e7fced6/tests/integration/.gitkeep -------------------------------------------------------------------------------- /tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import Application from '../app'; 2 | import config from '../config/environment'; 3 | import { setApplication } from '@ember/test-helpers'; 4 | import { start } from 'ember-qunit'; 5 | 6 | setApplication(Application.create(config.APP)); 7 | 8 | start(); 9 | -------------------------------------------------------------------------------- /tests/unit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oskarrough/ember-date-fns/00ba5630f0ccdff2cfac11f1f9c76a687e7fced6/tests/unit/.gitkeep -------------------------------------------------------------------------------- /tests/unit/helpers/date-format-test.js: -------------------------------------------------------------------------------- 1 | import { dateFormat } from 'dummy/helpers/date-format'; 2 | import { module, test } from 'qunit'; 3 | 4 | module('Unit | Helper | date format'); 5 | 6 | // test('it fails when it should', function(assert) { 7 | // let result = dateFormat(['42']); 8 | // console.log(result); 9 | // assert.ok(typeof result === 'string'); 10 | // assert.ok(result === 'Invalid Date', 'it is an invalid date'); 11 | // }); 12 | 13 | test('it is able to format a date object', function(assert) { 14 | let today = new Date(); 15 | let result = dateFormat([today, 'YYYY']); 16 | assert.ok(typeof result === 'string'); 17 | assert.ok(result !== 'Invalid Date', 'it is not an invalid date'); 18 | assert.ok(Number(result) >= 2017); 19 | }); 20 | 21 | test('it supports date timestamps', function(assert) { 22 | let today = new Date().getTime(); 23 | let result = dateFormat([today, 'YYYY']); 24 | assert.ok(Number(result) >= 2017); 25 | }); 26 | 27 | test('it supports date strings', function(assert) { 28 | let today = new Date().toString(); 29 | let result = dateFormat([today, 'YYYY']); 30 | assert.ok(Number(result) >= 2017); 31 | }); 32 | -------------------------------------------------------------------------------- /tests/unit/helpers/date-from-now-test.js: -------------------------------------------------------------------------------- 1 | import { dateFromNow } from 'dummy/helpers/date-from-now'; 2 | import { module, test } from 'qunit'; 3 | 4 | module('Unit | Helper | date from now'); 5 | 6 | test('it works', function (assert) { 7 | let result = dateFromNow([1481022124443]); 8 | assert.ok(typeof result === 'string', 'it is a string'); 9 | }); 10 | 11 | test('you can include a suffix', function (assert) { 12 | let result = dateFromNow([1481022124443], {addSuffix: true}); 13 | assert.ok(result.includes(' ago')); 14 | }); 15 | 16 | -------------------------------------------------------------------------------- /vendor/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oskarrough/ember-date-fns/00ba5630f0ccdff2cfac11f1f9c76a687e7fced6/vendor/.gitkeep --------------------------------------------------------------------------------