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

Allow arbitrary method output in CLDR formats #38

Open
autarch opened this issue Nov 12, 2016 · 2 comments
Open

Allow arbitrary method output in CLDR formats #38

autarch opened this issue Nov 12, 2016 · 2 comments
Labels

Comments

@autarch
Copy link
Member

autarch commented Nov 12, 2016

Migrated from rt.cpan.org #49767 (status was 'stalled')

Requestors:

From dmuey@cpan.org on 2009-09-16 18:42:33:

Hello again,

Last one I promise :)

Just FYI: I am filing this rt under DateTime::Locale instead DateTime
since ::Locale specifies formats, let me know if I should re-file under
DateTime (or if this simply won't be implemented), thanks.

strftime() has %s for 'The number of seconds since the epoch.'

Also it supported %{epoch} to have it call the DT method "epoch".

I can't seem to find an equivalent way to do 'The number of seconds
since the epoch.' with format_cldr()

$ perl -MDateTime -le 'print DateTime->now()->strftime("%B %{day}, %Y
%{hour_12}:%M:%S %p %{time_zone_long_name} == %s");'
September 16, 2009 6:24:23 PM UTC == 1253125463

$ perl -MDateTime -le 'print DateTime->now()->strftime("%B %{day}, %Y
%{hour_12}:%M:%S %p %{time_zone_long_name} == %{epoch}");'
September 16, 2009 6:24:33 PM UTC == 1253125473

$ perl -MDateTime -le 'print DateTime->now()->format_cldr("MMMM d, y
h:mm:ss a z == ???");'
September 16, 2009 6:24:40 PM UTC == ???

Is a CLDR %s equivalent currently available and I just missed it? (If so
what did I miss?)

If not: how [im]possible/[un]likley is it to be added?

@autarch
Copy link
Member Author

autarch commented Nov 12, 2016

From drolsky@cpan.org (@autarch) on 2009-10-02 01:32:56:

Also it supported %{epoch} to have it call the DT method "epoch".

I think supporting something like this in the CLDR output would be nice
but I haven't come up with anything that I think fits in with the CLDR
style. If you have any ideas please send them to datetime@perl.org.

@autarch
Copy link
Member Author

autarch commented Nov 12, 2016

From drolsky@cpan.org (@autarch) on 2012-11-18 17:41:06:

I've looked at this several times over the years and I've come to the
conclusion that there's no good way to do this. CLDR just uses random
letters as formats, so there's no good way to allow method names in the
format.

It's not that terrible to write:

$dt->format_cldr('MMM') . $dt->method

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

No branches or pull requests

1 participant