Skip to content

Commit

Permalink
docs(csm): update package documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
reugn committed Sep 27, 2024
1 parent 98def5b commit d0ff2c5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
21 changes: 12 additions & 9 deletions internal/csm/doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// "csm" is an internal package focused on solving a single task.
// Package csm is an internal package focused on solving a single task.
// Given an arbitrary date and cron expression, what is the first following
// instant that fits the expression?
//
Expand All @@ -10,14 +10,17 @@
// First, we must check from most significant (year) to least significant (second) for
// any field that is invalid according to the cron expression, and move it forward to the
// next valid value. This resets less significant fields and can overflow; advancing more
// significant fields. This process is implemented in CronStateMachine.findForward() (fn_find_forward.go).
// significant fields. This process is implemented in CronStateMachine.findForward()
// (fn_find_forward.go).
//
// Second, if no fields are changed by this process, we must perform the smallest possible step forward
// to find the next valid value. This involves moving forward the least significant field (second),
// taking care to advance the next significant field when the previous one overflows. This process is
// implemented in CronStateMachine.next() (fn_next.go).
// Second, if no fields are changed by this process, we must perform the smallest
// possible step forward to find the next valid value. This involves moving forward
// the least significant field (second), taking care to advance the next significant
// field when the previous one overflows. This process is implemented in CronStateMachine.next()
// (fn_next.go).
//
// NOTE: Some precautions must be taken as the "day" value does not have a constant radix. It depends
// on the month and the year. January always has 30 days, while February 2024 has 29. This is taken into account
// by the DayNode struct (day_node.go) and CronStateMachine.next() (fn_next.go).
// NOTE: Some precautions must be taken as the "day" value does not have a constant radix.
// It depends on the month and the year. January always has 30 days, while February 2024 has 29.
// This is taken into account by the DayNode struct (day_node.go) and CronStateMachine.next()
// (fn_next.go).
package csm
11 changes: 5 additions & 6 deletions internal/csm/node.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package csm

type csmNode interface {
// Returns the value held by the node.
// Value returns the value held by the node.
Value() int

// Resets the node value to the minimum valid value.
// Reset resets the node value to the minimum valid value.
Reset()

// Changes the node value to the next valid value.
// Returns true if the value overflowed and false otherwise.
// Next changes the node value to the next valid value.
// It returns true if the value overflowed and false otherwise.
Next() bool

// Checks if the current node value is valid.
// findForward checks if the current node value is valid.
// If it is not valid, find the next valid value.
// Returns true if the value changed and false otherwise.
findForward() result
}

Expand Down

0 comments on commit d0ff2c5

Please sign in to comment.