![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Dater
Convert a period of time expressed in a literal way like 'in 2 days' to a formatted future date with a given format. It aims to be helpful in regression tests when you have to deal with dinamic dates.
You can also, convert dates from 'dd/mm/yyyy' to 'yyyy-mm-dd' or viceversa.
If you want to pass a formatted date like dd/mm/yyyy to convert to yyyy-mm-dd, you have to take care about only two things with the argument:
Year number must have four digits.
Month number must be always in the middle.
Add this line to your application's Gemfile:
gem 'dater'
And then execute:
$ bundle
Or install it yourself as:
$ gem install dater
require 'dater'
date=Dater::Resolver.new('%Y-%m-%d')
#date.for(String)
#Example:
date.for("in 2 weeks")
=begin
String could be:
"in 4 days" # => yyyy-mm-dd (date for 4 days from the date of today)
"in 2 weeks" # => yyyy-mm-dd (date for 2 weeks from the date of today)
"in 10 months" # => yyyy-mm-dd (date for 10 months from the date of today)
"in 1 year" # => yyyy-mm-dd (date for 1 year from the date of today)
"next day" # => yyyy-mm-dd (date for tomorrow from the date of today)
"next week" # => yyyy-mm-dd (adds a period of time for a week and returns the date)
"next month" # => yyyy-mm-dd (adds a period of time for a month and returns the date)
"next year" # => yyyy-mm-dd (adds a period of time for a year and returns the date)
"yesterday" # => yyyy-mm-dd (date of yesterday)
"today" # => yyyy-mm-dd (date of today)
"tomorrow" # => yyyy-mm-dd (date of tomorrow)
"2 days ago" # => yyyy-mm-dd (N days ago from today)
"3 weeks ago" # => yyyy-mm-dd (N weeks ago from today)
"4 months ago" # => yyyy-mm-dd (N months ago from today)
"1 year ago" # => yyyy-mm-dd (N year ago from today)
#Some equivalent methods you can use:
date.yesterday
date.today
date.tomorrow
date.sunday
date.monday
date.thuesday
date.wednesday
date.thursday
date.friday
date.saturday
date.next_day
date.next_week
date.next_month
date.next_year
=end
later and before
Giving the keywords 'later' or 'before' at the end of the string, Dater allows you to request dates from the last date requested. If there isn't any date requested previously, it takes as last requested date today's date
date.for("2 days later") # => You will get the date for two days later from the last requested date.
Example: Supose that the last requested date was 10/12/2013 (dd/mm/YYYY), using '2 days later' will give the result '12/12/2013'.
date.for("1 month before") # => You will get the date for one month before from the last requested date.
If the argument is nil, it will return nil. But you can initialize Dater object with 'today_for_nil' flag like:
date = Dater::Resolver.new("%Y-%m-%d", true)
date.for #=> yyyy-mm-dd (date of today)
You'll find format directives at following link:
http://apidock.com/ruby/Time/strftime
It does not work correctly with leap-years and calculates months of 30 days only.
It supports following languages: English (lang='en'), Spanish (lang='es') and Portuguese (lang='pt')
Si deseas usar esta gema en español puedes inicializar la clase de la siguiente manera:
fecha=Dater::Resolver.new('%Y-%m-%d', false, "es")
fecha.para("en 1 semana")
fecha.ayer
fecha.hoy
fecha.mañana
Con eso puedes pasar argumentos en idioma español (por ejemplo 'en 2 días', 'en 10 meses', 'en 1 año')
Se você quiser usar esta gem em Português, você pode inicializar a classe da seguinte forma:
data=Dater::Resolver.new('%Y-%m-%d', false, "pt")
data.para("em 2 dias")
Federico Hertzulis
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that dater demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.