Giter VIP home page Giter VIP logo

relative-time-element's Issues

Travis CI

After this repo is public, we can setup Travis CI phantomjs builds.

Bug displaying 'in 3 hours'

Looks like there could be a bug here, if you are using this library on the Github User Feed Page.

I believe this should be 3 hours ago, as opposed to in 3 hours unless github is predicting the future.

Mind blown

see screenshot below:

Screenshot 2019-08-28 at 13 51 10

Can't get <relative-time> working with PWA & LitElement

I have been using time-elements for a Polymer 2.0 app successfully and when I came to upgrade to polymer 3.0 I decided to go straight to PWA

However I can't get time-elements working even though I'm passing the same data as before.

I've used NPM to get hold of the code, and it's listed in package.json and I can see it in node_modules

I've added an import to my component
import 'time-elements/dist/time-elements.js';

and I'm using the tag as normal way
<relative-time datetime="${event.created}"></relative-time> in the _render() method.

The code is loaded when I access the page but the time doesn't seem to render, and nothing written to the console.

I've probably done something stupid but I'd appreciate some help, please.

Register bower package

Once the repo is public.

$ bower register time-elements https://github.com/github/time-elements.git

tell how to properly import this into other webcomponents

Somewhat related to #81. Right now polymer lint will complain

 warning [undefined-elements] - The element relative-time is not defined

If I just have this at the end of modules:

 ...
 <script src="../bower_components/time-elements/time-elements.js"></script>
</dom-module>

Performance

Not using semicolon for end of line is terrible for performance.

Translation support

If this element supports translation, it would be great!

Example:
<time datetime="2015-02-23T09:51:57Z" is="relative-time" lang="ja-jp">Feb 23, 2015</time>

Make "ago" optional for time-ago

What do you think about making "ago" optional for time-ago? It's often useful to get a human-readable time span and combine it with custom suffix, e.g.: 2 days since the last meeting, 10 years of experience. moment.js supports similar feature via a boolean argument to fromNow(true) method.

time-elements + Polymer 1.0 won't work

It seems that time-elements.js doesn't seem to work with Polymer 1.0. Couldn't really grasp what was wrong. Would be great if it was fixed/supported!

Formatting not working on page reload (looking for fallback)

On an initial page load or page reload, the formatting is not working (Using Rails + Turbolinks). I used to solve this by calling updateNowElements directly but now that Rails 6 switch to webpacker, i'd like to know how to access updateNowElements after importing time-elements via

import timeElements from 'time-elements/dist/time-elements.js'

[question] Manual trigger

Hi guys,

I wasn't able to get this to work to elements that were created after the document has sent the ready event. Is there a way to manually transform an element, or to rerun the search on the page to parse the <time> elements again?

Thanks!

Compatibility broken with Web components 1.0.0

When used in Firefox, I get the following error:

TypeError: document.registerElement is not a function

screenshot from 2017-06-27 11-16-56

The polyfill with version 1.0.0 of web component assumes that window.customElements.define is used.

Expose time formatting

The source code contains an implementation of strftime and a few functions that use it but there's no way to access it directly. It would be nice if you could use it to customize the format of the title attribute and other strings.

HTML Import

Any way you guys can make a time-elements.html file which simply imports the javascript file.

Add a file named: time-elements.html
the contents of that file should be exactly
<script src="./time-elements.js"></script>

This is the proper way to import web components because importing an html file twice does nothing while importing a javascript file twice will try to run the code twice.

Drop moment.js dependency

We expose a strftime format expression rather than the moment tokens. This means we aren't coupled to moment.js. Removing moment.js would give this component and overall smaller footprint as well as make it easier to install.

Avoid is="" API

Safari 10 will be supporting Custom Elements soon, but won't support is="".

We should rewrite this extension without extending <time> and just do <relative-time> and <local-time>.

Hopefully we can get github.com updated long before so future Enterprise versions will be ready with this change. Unsure if the Polymer Custom Element polyfill will correctly cover a partial Custom Elements implementation.

To: @dgraham @mislav
CC: @notwaldorf @github/js

Jalali Calendar

Unfortunately all of new elements (time, date-picker, ...) don't implement Jalali calendar in them...
We should do something about it.

Custom prefix for relative-time

I noticed that for <relative-time> which is further than 1 month ago we show example: on 14 April 2018

Would it be possible to add custom prefix, which if not specified would default to on (for backwards compatibility) but in case I could specify empty string so I would get just 14 April 2018?

"Maximum call stack size exceeded error" with 3.0.9

It looks like the update to 3.0.9 introduced an infinite loop in the <relative-time /> element.

Repro Link:
https://codesandbox.io/s/thirsty-joliot-44k9p
Repro Steps:

  • Open link
  • Open browser console
  • Refresh
Uncaught RangeError: Maximum call stack size exceeded.
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at HTMLElement.attributeChangedCallback (time-elements-legacy.js:248)
    at evaluate (index.js? [sm]:6)
    at Jn (eval.js:61)
    at e.value (transpiled-module.ts:980)
    at e.value (manager.ts:361)
    at t (transpiled-module.ts:958)
    at loadResources (index.html:3)

Compare to https://codesandbox.io/s/wizardly-dew-7pih0 which is using 3.0.8 and does not have the issue.

Here is the relevant code:

if (title && (!currentTitle || currentTitle === oldTitle)) {
        this.setAttribute('title', title);
      }

which I think was modified in this PR:
#129

time-ago wrong calcul

For current date 2015-02-23T00:00:00.000Z (like)

The following html :

Give this result :
117y

Or it's should give 115 or maybe 116 not 117 !

Note : for date 002-02-01T00:00:00.000Z It's even more obvious.

How to use directly without npm?

I'd like to just do <script src=... without hosting my own time-elements.js file. Can't seem to find anything like this in the README.

How to do it?

add an attribute to accept millisecond format time

In some case we receive millisecond format time from server, currently I have to construct a date object and convert it into a string of acceptable format in a customized filter, that's really inconvenient. So have you guys considered to define a different attribute to accept time of this format? like time="1414579265159"

Relative time

Is there any way to make it possible to display "on the 7 of March" instead of "on 7 March" ?

Mixed languages in '<relative-time>'

Issues lists on GitHub have relative times displayed in two languages. For example, my os/browser is set to the Slovak language and when I open a GitHub issues list, some relative times are displayed as translated (red) and some in English (blue) - see the attached screenshot.

Browser: Google Chrome 74.0.3729.169
OS: macOS Mojave 10.14.4

github

Override content for local-time and default formatting

I found 2 problems: appending content in chrome and no default formatting

No default formatting:

Source:

<local-time datetime="2018-08-24T16:57:42.604Z">Aug 24, 2018 23:57:42</local-time>

Result:

<local-time datetime="2018-08-24T16:57:42.604Z" title="Aug 24, 2018, 11:57 PM GMT+7">Aug 24, 2018 23:57:42</local-time>

would be much easier to start if it would apply default formatting month="short" day="numeric" year="numeric" hour="numeric" minute="numeric" (or similar) and may be update-content=false to prevent updating content

Appending content in chrome:
Source:

<local-time datetime="2014-04-01T16:30:00-08:00" month="short" day="numeric" year="numeric" hour="numeric" minute="numeric">April 1, 2014 4:30PM PDT</local-time>

Result:

<local-time datetime="2014-04-01T16:30:00-08:00" month="short" day="numeric" year="numeric" hour="numeric" minute="numeric" title="Apr 2, 2014, 7:30 AM GMT+7">Apr 2, 2014 7:30 AMApril 1, 2014 4:30PM PDT</local-time>

Develop a true Web Component version of time-elements

I'm trying to use time-elements in an application built on top of Polymer (2.0) and Web Components and I can't seem to get this to work since there is no real web component defined for these custom HTML tags. I know this is added to the Web Components website but it only has the .js file and no HTML files to import. My request is two-fold:

  1. Make full-blown Web Components for each custom HTML tag (eg. <relative-time>, <local-time>, etc.) with HTML imports.
  2. Is there a way to properly use the current implementation in a Polymer 2.0 Web Component?

Thank you for your work!

Edit: I forgot to mention that I'm relatively new to Web Components and Polymer so it's very possible that I'm missing something and time-elements in its current form is already a real web component and I just don't realize it.

Use of `from now` carries vague implication of future tense

Had a situation on this PR. As I filled in the comment, I saw:

myii requested review from aboe76 and noelmcloughlin 3 minutes from now

To be fair, this soon became:

myii requested review from aboe76 and noelmcloughlin 4 minutes ago

So probably just a glitch. Just to be clear, from now connotes a future event, as mentioned on this page.

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.