Skip to content

Custom Formats Are Not Working #128

@scarrick68

Description

@scarrick68

I am trying to set a default DateTime format for my app, so I did this in a JS file and included it into my application.js

import LocalTime from "local-time"

LocalTime.config.i18n["en"]["date"]["formats"]["default"] = "%b %e, %Y"
LocalTime.config.i18n["en"]["datetime"]["formats"]["default"] = "%b %e, %Y"
LocalTime.config.i18n["en"]["time"]["formats"]["default"] = "%b %e, %Y"

LocalTime.start()

I printed in the console and see the updated default format, but all of my DateTimes still show in the original default format. I am only interested in DateTime. I set the default on all of them just in case I was passing an unexpected type.

I called local_time in the view like this with :my_format being added to the formats instead of overriding default:

<%= local_time(@my_date_time) %>

<%= local_time(@my_date_time, format: :my_format) %>
<%= local_time(@my_date_time, :my_format) %>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions