Giter Club home page Giter Club logo

Comments (3)

tobyhinloopen avatar tobyhinloopen commented on August 22, 2024

Isn't there some kind of common library that can represent a range of dates (EG a range from 17 years ago to 18 years ago) so we can just Enum.random it?

from faker.

lauraannwilliams avatar lauraannwilliams commented on August 22, 2024

Date Ranges are a 1.6 feature from the looks of things
https://github.com/elixir-lang/elixir/blob/741b6adbd8c4be1735dc9c605b8d5cdc7b73bc1a/lib/elixir/lib/calendar/date_range.ex#L1

Perhaps something like this https://medium.com/@natetsai/implementing-date-ranges-in-elixir-384460f3b7fa ?

or this seems very tidy https://stackoverflow.com/questions/30951318/how-to-create-a-stream-and-list-of-dates

from faker.

tobyhinloopen avatar tobyhinloopen commented on August 22, 2024

Fixed by MR #116

Enum.map(0..1000, fn i -> Faker.Date.date_of_birth(1).day end) 
|> Enum.reduce(%{}, fn day, acc -> Map.update(acc, day, 0, &(&1 + 1)) end)
%{1 => 40, 2 => 27, 3 => 35, 4 => 39, 5 => 25, 6 => 32, 7 => 21, 8 => 18,
  9 => 37, 10 => 28, 11 => 24, 12 => 28, 13 => 27, 14 => 30, 15 => 43, 16 => 26,
  17 => 31, 18 => 29, 19 => 36, 20 => 31, 21 => 31, 22 => 38, 23 => 21,
  24 => 41, 25 => 42, 26 => 32, 27 => 39, 28 => 36, 29 => 44, 30 => 29,
  31 => 10}

from faker.

Related Issues (20)

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.