Giter Site home page Giter Site logo

ryan-haskell / date-format Goto Github PK

View Code? Open in Web Editor NEW
51.0 3.0 27.0 77 KB

A reliable way to format dates and times in Elm.

Home Page: https://package.elm-lang.org/packages/ryan-haskell/date-format/latest

License: BSD 3-Clause "New" or "Revised" License

Elm 100.00%
elm date format moment

date-format's People

Contributors

dway8 avatar felipehummel avatar gampleman avatar isaacseymour avatar jpagex avatar mateusfreira avatar mgold avatar monty5811 avatar punie avatar rl-king avatar ryan-haskell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar

date-format's Issues

format is misscalculating day?

Hey, I'm trying to convert some time in seconds to string using format. My current approach is working but its showing the wrong amount of days.

DateFormat.format
        [ DateFormat.dayOfYearNumber
        , DateFormat.text "D "
        , DateFormat.hourMilitaryNumber
        , DateFormat.text "H "
        , DateFormat.minuteNumber
        , DateFormat.text "M "
        , DateFormat.secondNumber
        , DateFormat.text "S"
        ]
        utc
        (Time.millisToPosix (someTimeInSeconds * 1000))

When I try this with someTimeInSeconds = 807627. It will return 10 days instead of 9.

How is weekOfYearNumber supposed to behave?

I am wondering how is the weekOfYearNumber intended to work? It seems that it does work properly when the year changes, eg. week number can jump from 53 to 1 while day of the week is changing from Tuesday to Wednesday.

For example:

Tuesday 2019-12-31 18:00 GMT (posix 1577815200000) gives output week=53
Wednesday 2020-01-01 18:00 GMT (posix 1577901600000) gives output week=1

If I have understood correctly, there are several standards on how to calculate the week number but for example ISO week date states that "Each week's year is the Gregorian year in which the Thursday falls". So in the previous example Tuesday should also be part of week 1 of year 2020 if following the ISO week date standard.

Version for 0.18

Would be great to have a version for 0.18, so that I can update my code dealing with dates/times before making the big switch for the code as a whole

Tags were moved, but not published

I started to get complilation error: Same for 2.2.0 and 2.3.0

I downloaded the source code for ryannhg/date-format 2.3.0 from:

https://github.com/ryannhg/date-format/zipball/2.3.0/

But it looks like the hash of the archive has changed since publication:

Expected: 70c67866fed499bec685f43f23fea279556757f2
Actual: 86534146f5a550bb8e87b87a7484ea5732090bb5

Releases seems to be broken

Hi Ryan, I'm not sure how, but the latest changes to your repo seem to have broken the releases.

Our CI started failing around when you made your last commit. It appears to fail when we're running some elm tooling.

Relevant logs:

Failing running elm-test-rs

 elm-test-rs --fuzz 10
-- CORRUPT PACKAGE DATA --------------------------------------------------------

I downloaded the source code for ryannhg/date-format 2.3.0 from:

    https://github.com/ryannhg/date-format/zipball/2.3.0/

But it looks like the hash of the archive has changed since publication:

  Expected: 70c67866fed499bec685f43f23fea279556757f2
    Actual: 86534146f5a550bb8e87b87a7484ea5732090bb5

This usually means that the package author moved the version tag, so report it
to them and see if that is the issue. Folks on Elm slack can probably help as
well.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Failing during elm-graphql

$ elm-graphql --schema-file ../hasura/schema.gql --output src/elm/ --base Builder --scalar-codecs CustomScalarCodecs && git apply patches/hasura-branch-main.patch
Generating files...
Command failed: elm make src/elm/Builder/VerifyScalarCodecs.elm --output=/dev/null
-- CORRUPT PACKAGE DATA --------------------------------------------------------

I downloaded the source code for ryannhg/date-format 2.3.0 from:

    https://github.com/ryannhg/date-format/zipball/2.3.0/

But it looks like the hash of the archive has changed since publication:

  Expected: 70c67866fed499bec685f43f23fea279556757f2
    Actual: 86534146f5a550bb8e87b87a7484ea5732090bb5

This usually means that the package author moved the version tag, so report it
to them and see if that is the issue. Folks on Elm slack can probably help as
well.


--------------------------------------------
        INVALID SCALAR DECODERS FILE
--------------------------------------------

Your custom scalar decoders module, `CustomScalarCodecs`, is invalid.

This is because either:

1) This is the first time you've run this CLI with the `--scalar-codecs` option.
  In this case, get a valid file, you can start by copy-pasting `Builder.ScalarCodecs`. Then change the module name to `CustomScalarCodecs`
  and you have a valid starting point!
2) You added or renamed a Custom Scalar in your GraphQL schema.
   To handle the new Custom Scalar, you can copy the relevant entries from `CustomScalarCodecs`.

Check the following:
    * You have a module called `CustomScalarCodecs`
    * The module is somewhere in your elm path (check the `source-directories` in your `elm.json`)

    You must:
    * Have a type for every custom scalar
    * Expose each of these types
    * Expose a `codecs` value

    Above the dashes (----) there are some details that might help you debug the issue. Remember, you can always
    copy-paste the `Builder.ScalarCodecs` module to get a valid file.

    After you've copy pasted the template file, or tried fixing the file,
    re-run this CLI command to make sure it is valid.
    
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

French suffix of days

Hello,

I think there is a mistake with dayOfMonthSuffix for french language.
In french, only the first day of the month need the suffix "er", all the others are just left as it.
It seems that you add "e" as suffix for all the other days.

toFrenchOrdinalSuffix : Int -> String
toFrenchOrdinalSuffix n =
    if n == 1 then
        "er"

    else
        "e"

Problem in timezone

Hello.

First of all, thanks for this package.
Today I was having a problem with the posix from 2018/10/04 being converted to 2018/01/04. Then I updated to 2.0.1 and everything was ok. Then I decided to not use Time.utc and use my local timezone (-3) using Time.here, and the format function seems to always use Time.utc, even if I pass my local time zone.

Would you mind checking if the function is correct?
Thanks!

Localized formatting

There should be a way to localize formatting for dates.

A few people have submitted PRs to my formatting library over the years. (I don't plan to update it to 0.19 - your token approach is better.) The results are here. You don't necessarily have to add all the localizations, but having a way for others to do them is useful. I think you hit upon a good pattern with the record of functions in the Relative module.

Expose DateFormat.defaultOptions

If I am writing a translation library, it would be nice to be able to work with DateFormat in a generic way. DateFormat.defaultOptions is a good default for the English format. However, the only way to use it is to use DateFormat.format instead of DateFormat.formatWithOptions. I would need to use DateFormat.formatWithOptions for every other language, though. So English becomes this weird special case.

So right now I either have to define my own English DateFormat.FormatOptions and use it with DateFormat.formatWithOptions, or I have to handle English as a special case and call DateFormat.format when formatting dates in English.

It would be nice to have DateFormat.defaultOptions exposed.

Please add a CHANGELOG

This is great package, thanks for making it.

Please add a CHANGELOG, this is very useful when trying to upgrade, specially when functions are removed or renamed.

Thanks

Language configs should be provided from outside

Love the library thank you for this awesome work :)

MomentJS is awesome as well however the biggest pain point for me was the size of the language and internalization options, however, most of the time I use two or three languages at most.

I think language data could be given as a dict from outside with typed configuration values and language codes as keys because every language will increase the size of the package and limits the language aspect. Maybe every language set can be a separate package this way

Any ideas or plans about how can the internalization problem decoupled from the date formatting problem at hand?

Expose defaultRelativeOptions

I think you should expose DateFormat.Relative.defaultRelativeOptions.

What if I want to say "right now" instead of "just now"? I could use the record update syntax and leave everything else in place.

Just a thought.

Add support for justinmimbs/date

I have a Date value that I'd like to format using this package. This seems like a natural thing to do since this package is called date-format but currently it seems to only support Time.Posix.

That said, there might be some design consideration if you decide to add this. For example, should phantom types be used to prevent the user from using hour, minute, second, etc with a Date value? Or should those values just default to 0?

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.