floraison / fugit

time tools (cron, parsing, durations, ...) for Ruby, rufus-scheduler, and flor
MIT License
353 stars 29 forks source link

If given 6 fields, the first one is interpreted as seconds #91

Closed dhs-rec closed 8 months ago

dhs-rec commented 8 months ago

Issue description

If a string of 6 fields is fed into Fugit.parse, the first one is interpreted as seconds, which is wrong (at least according to my understanding of cron).

How to reproduce

require 'fugit'
p Fugit.do_parse('1 2 3 4 5 6').next_time
p Fugit.do_parse('1 2 3 4 5 6').class

Current behavior

The above code prints:

2024-05-04 03:02:01 +0200
Fugit::Cron

Expected behavior

It should raise an exception.

Context

Linux XXX 6.1.0-13-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.55-1 (2023-09-29) x86_64 GNU/Linux
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
[:env_tz, nil]
(secs:1698224523.8174794,utc~:"2023-10-25 09:02:03.8174793720245361",ltz~:"CEST")
(etz:nil,tnz:"CEST",tziv:"2.0.6",tzidv:nil,rv:"3.2.2",rp:"x86_64-linux",win:false,rorv:nil,astz:nil,eov:"1.2.7",eotnz:#<TZInfo::DataTimezone: Europe/Berlin>,eotnfz:"+0200",eotlzn:"Europe/Berlin",eotnfZ:"CEST",debian:"Europe/Berlin",centos:nil,osx:"Europe/Berlin")
[:fugit, "1.9.0"]
[:now, 2023-10-25 11:02:03.998271626 +0200, :zone, "CEST"]
jmettraux commented 8 months ago

Hello, thanks for reporting that, but it's a feature, not a bug. It's been like that since day zero.

I will mention that in the README and then close this issue.

dhs-rec commented 8 months ago

OK, that's also fine.