Giter Site home page Giter Site logo

willrax / ember-luxon Goto Github PK

View Code? Open in Web Editor NEW
22.0 2.0 7.0 366 KB

๐Ÿ• ๐ŸŒ [deprecated] Addon thats brings Luxon to Ember applications.

License: MIT License

JavaScript 90.11% HTML 9.55% Handlebars 0.33%
ember-cli ember luxon ember-addon

ember-luxon's Introduction

ember-luxon

Deprecated. I no longer work with Ember so it's tricky to keep this up to date. If you require this library, I'd suggest forking it. Alternatively, install luxon directly and copy the helpers in.

NPM version CircleCI

An addon to allow importing of Luxon in your Ember Apps.

Installation

  • ember install ember-luxon;

Most modern browers will work fine with luxon. If you need to support legacy browsers you will need to include some polyfills.

You can provide an option in your apps ember-cli-build.js file and we'll add intl.js to your build.

'ember-luxon': {
  includeIntlPolyfill: true
}

See the Luxon support matrix for more information and which browsers support which features and other caveats.

Usage

import { DateTime, Duration, Info, Interval, Settings, Zone } from 'ember-luxon';
import Component from '@ember/component';

export default Component.extend({
  theTime: computed(function() {
    return DateTime.local()
  })
});

Helpers

Ember luxon provices some helpers for use in templates.

luxon

Given a string and a format it will generate a luxon datetime object.

{{luxon "2014 Aug 06" "yyyy LLL dd"}}

luxon-diff

This will determine the length of time between two days. Precision is optional and will default to milliseconds.

{{luxon-diff dateOne dateTwo}}                  /* 86400000
{{luxon-diff dateOne dateTwo precision="days"}} /* 1

luxon-format

Given a datetime object it will format it. If you don't provide a format string ember-luxon will default to using local formatting.

{{luxon-format dateOne format="yyyy LLL dd"}} /* "2014 Aug 06"
{{luxon-format dateOne}}                      /* "4/20/2017"

luxon-is-after

Will return true or false depending on whether the first dateTime is after the second.

{{luxon-is-after earlyDate lateDate}} /* true
{{luxon-is-after lateDate earlyDate}} /* false

luxon-is-before

Will return true or false depending on whether the first dateTime is before the second.

{{luxon-is-before earlyDate lateDate}} /* true
{{luxon-is-before lateDate earlyDate}} /* false

luxon-is-before

Will return true or false depending on whether the first dateTime is contained within a pair of dates.

{{luxon-is-before dateTime startDate endDate}} /* true

luxon-is-same

Will return true or false depending on whether the first dateTime is the same as the other date. You can set the precision here to verify if it is the day, millisecond, hour etc.

{{luxon-is-same dateTime dateTime}}                        /* true
{{luxon-is-same dateTime dateTimeTwo precision="day"}}     /* true
{{luxon-is-same dateTime dateTimeThree precision="month"}} /* true

ember-luxon's People

Contributors

buschtoens avatar cibernox avatar dependabot-support avatar dependabot[bot] avatar ember-tomster avatar jasonmit avatar philippgrieser avatar terminalstar avatar willrax avatar

Stargazers

 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

ember-luxon's Issues

Not compatible with Ember-CLI 3.2.x

Circular dependency: tmp/rollup-cache_path-aCxGLew4.tmp/build/impl/locale.js -> tmp/rollup-cache_path-aCxGLew4.tmp/build/settings.js -> tmp/rollup-cache_path-aCxGLew4.tmp/build/impl/locale.js
Circular dependency: tmp/rollup-cache_path-aCxGLew4.tmp/build/datetime.js -> tmp/rollup-cache_path-aCxGLew4.tmp/build/duration.js -> tmp/rollup-cache_path-aCxGLew4.tmp/build/impl/locale.js -> tmp/rollup-cache_path-aCxGLew4.tmp/build/datetime.js
Circular dependency: tmp/rollup-cache_path-aCxGLew4.tmp/build/datetime.js -> tmp/rollup-cache_path-aCxGLew4.tmp/build/interval.js -> tmp/rollup-cache_path-aCxGLew4.tmp/build/datetime.js
Circular dependency: tmp/rollup-cache_path-aCxGLew4.tmp/build/datetime.js -> tmp/rollup-cache_path-aCxGLew4.tmp/build/info.js -> tmp/rollup-cache_path-aCxGLew4.tmp/build/datetime.js

Build Error (broccoli-persistent-filter:Babel > [Babel: PROJECTNAME]) in luxon.js

luxon.js: Property object of MemberExpression expected node to be of a type ["Expression"] but instead got null

Stack Trace and Error Report: /var/folders/sk/f8z9r_gd3qx0ycfccdxbfd7c0000gn/T/error.dump.406a591d1c334e86c29e015452028671.log

I'll try to fix this in our fork and will try to provide a PR.

Feature Request: Support automatic import of polyfills where required

First of all, thank you very much for rewarding my laziness and creating this addon for me. Or in a more serious way: Thanks for doing this, it's much appreciated.

As we plan to move to Luxon for our next projects, I'd love to help making this a full fledged replacement solution for ember-moment.

Luxon requires rather new browsers. In case support for legacy browsers is requires, either Intl.js or support for time zones has to be polyfilled as described in the Luxon documentation

This addon should provide options to automatically polyfill these features based on the targets.js provided by Ember-CLI or based on options set in ember-cli-build.js.

  • Provide Polyfills based on targets.js
    • Use local polyfills
    • Use polyfill.io
  • Allow configuration overrides in ember-cli-build.js

(Any of my feature requests could also be moved to a separate addon, lets discuss!)

Feature Request: Ember Data Transform

A feature that is not supported by ember-moment, but is available as additional addon.

Ember Data has a date transform that deserializes ISO dates to native Date() objects. Having a similar transform that provides Luxon objects instead is highly desired as it makes sense to have any occurrence of calendrical data in one format (especially given the welcome deviations in Luxon).

Given that luxon has multiple data structures, this addon should provide a transform for any reasonable variant.

Change Request: Consider providing luxon as direct import, maybe in additional addon

Ember-Moment and others allow you to import the library they shim by name, i.e.

import 'moment' from 'moment';

I think doing the same with this addon might be useful, comparing

import { DateTime } from 'ember-luxon/luxon'; 
// vs
import { DateTime } from 'luxon'; 

The current option, while it safeguards against namespace collisions feels rather unnatural given that Luxon is provided as a ES6 module and uses the latter option in their own documentation.

Feature Request: Provide template helpers for formatting dates

ember-moment provides a range of helpers:
https://github.com/stefanpenner/ember-moment#helpers

{{moment '12-25-1995' 'MM-DD-YYYY'}}
{{moment-format '12-25-1995' 'MM/DD/YYYY' 'MM-DD-YYYY'}} {{!-- outputFormat and inputFormat are optional --}}
{{moment-from-now (now) hideSuffix=true}} {{!-- hideSuffix is optional --}}
{{moment-to-now (unix timeStamp) date hidePrefix=true}} {{!-- hidePrefix is optional --}}
{{moment-duration number units}} {{!-- units is optional --}}
{{moment-calendar date referenceDate}} {{!-- reference date is optional --}}
{{moment-diff dateA dateB precision='day' float=true}} {{!-- precision is optional, float is optional --}}
{{is-before date comparison precision='year'}} {{!-- precision is optional --}}
{{is-after date comparison precision='year'}} {{!-- precision is optional --}}
{{is-same date comparison precision='year'}} {{!-- precision is optional --}}
{{is-same-or-before date comparison precision='year'}} {{!-- precision is optional --}}
{{is-same-or-after date comparison precision='year'}} {{!-- precision is optional --}}
{{is-between date comparisonA comparisonB precision='year' inclusivity='[)'}} {{!-- precision is optional, inclusivity optional  --}}

ember-luxon should provide similar drop-in replacements to make it easier to switch.

  • {{luxon '12-25-1995' 'MM-DD-YYYY'}}
  • {{luxon-format '12-25-1995' 'MM/DD/YYYY' 'MM-DD-YYYY'}} {{!-- outputFormat and inputFormat are optional --}}
  • {{luxon-duration number units}} {{!-- units is optional --}}
  • {{luxon-diff dateA dateB precision='day' float=true}} {{!-- precision is optional, float is optional --}}
  • {{is-before date comparison precision='year'}} {{!-- precision is optional --}}
  • {{is-after date comparison precision='year'}} {{!-- precision is optional --}}
  • {{is-same date comparison precision='year'}} {{!-- precision is optional --}}
  • {{is-same-or-before date comparison precision='year'}} {{!-- precision is optional --}}
  • {{is-same-or-after date comparison precision='year'}} {{!-- precision is optional --}}
  • {{is-between date comparisonA comparisonB precision='year' inclusivity='[)'}} {{!-- precision is optional, inclusivity optional --}}

Not supported by Luxon:

{{moment-calendar date referenceDate}} {{!-- reference date is optional --}}
{{moment-from-now (now) hideSuffix=true}} {{!-- hideSuffix is optional --}}
{{moment-to-now (unix timeStamp) date hidePrefix=true}} {{!-- hidePrefix is optional --}}

Remove ember-rollup

When attempting to upgrade to ember-cli 2.18, we get an error at the build stage:
screen shot 2018-01-18 at 17 42 31

The log file suggests rollup is the cause and removing ember-luxon results in a successful build.

maintainers?

Does this repo need maintainers to get things merged in a timely manner?

Feature Request: Computed Property Macros

ember-moment provides a few macros which deliver computed properties for various variants that can even be composed together: duration, humanize, locale, tz, format, calendar, moment, toNow, fromNow.

More details in their Computed Property Macro Documentation

I think it's reasonable to provide at least the same or event a larger set of helpers in the same fashion to make it easier to convert projects to Luxon.

Dependabot couldn't reach artifacts.netflix.com as it timed out

Dependabot couldn't reach artifacts.netflix.com as it timed out.

Is artifacts.netflix.com accessible over the internet? If it is then this may be a transitory issue and can be ignored - Dependabot will close it on its next successful update run.

You can mention @dependabot in the comments below to contact the Dependabot team.

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.