8000 Calculating and Displaying Durations · Issue #790 · ember-intl/ember-intl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Calculating and Displaying Durations #790
Closed
@srsgores

Description

@srsgores

Currently testing on version 3, and not sure the best way to display durations. Currently, I have this:

import Component from "@ember/component";
import {computed} from "@ember/object";

export default Component.extend({
	entry: null,
	duration: computed("entry.startTime", "entry.endTime", function() {
		if (this.get("entry.startTime") && this.get("entry.endTime")) {
			return this.get("entry.endTime") - this.get("entry.startTime");
		}
		return 0;
	}),
});

Where duration is a value in milliseconds, so I can do something like:

{{t "entry.duration" duration=entry.duration}}

And the translation is:

entry:
    duration: |
        {duration,
            >60000 {minutes}
            >3600000 {hours}
        }

What I really want is to use something like format-relative, but without the "days ago" part. How can I change that functionality, and then pass in a duration property?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0