Skip to content

Commit 0846d90

Browse files
committed
♻️ refactor: update codebase #2
1 parent 70a0765 commit 0846d90

6 files changed

Lines changed: 27 additions & 25 deletions

File tree

docs/GETTING_STARTED.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,10 +1892,10 @@ var startOfEpoch = timefy.MustParse("2020-01-01")
18921892

18931893
## 24. Enterprise Use Cases
18941894

1895-
The `_example/` directory contains five complete, runnable enterprise programs
1895+
The `examples/` directory contains five complete, runnable enterprise programs
18961896
that demonstrate production-grade patterns.
18971897

1898-
### `_example/billing/` — SaaS Subscription Billing
1898+
### `examples/billing/` — SaaS Subscription Billing
18991899

19001900
**Business problem:** A multi-tenant SaaS platform bills customers monthly,
19011901
quarterly, and annually. Customers sign up mid-period and receive pro-rated
@@ -1918,10 +1918,10 @@ charges. Some plans include a free trial period.
19181918
| `DurationInDays` | Pro-rate day counting |
19191919

19201920
```bash
1921-
cd _example/billing && go run main.go
1921+
cd examples/billing && go run main.go
19221922
```
19231923

1924-
### `_example/global_team/` — Multi-Timezone Team Coordination
1924+
### `examples/global_team/` — Multi-Timezone Team Coordination
19251925

19261926
**Business problem:** An engineering organization spans five cities. The
19271927
platform must find meeting overlap windows, detect business-hour availability,
@@ -1940,10 +1940,10 @@ and generate cross-team working-day schedules that respect public holidays.
19401940
| `New(t).TimeAgo()` / `TimeUntil()` | Release timeline display |
19411941

19421942
```bash
1943-
cd _example/global_team && go run main.go
1943+
cd examples/global_team && go run main.go
19441944
```
19451945

1946-
### `_example/audit/` — Enterprise Audit Trail & Compliance
1946+
### `examples/audit/` — Enterprise Audit Trail & Compliance
19471947

19481948
**Business problem:** A financial services platform records all data-access
19491949
events, enforces GDPR Article 33 (72-hour breach notification), detects SLA
@@ -1965,10 +1965,10 @@ breaches for support tickets, and generates CISO reports.
19651965
| `New(t).TimeAgo()` | Human-readable event age |
19661966

19671967
```bash
1968-
cd _example/audit && go run main.go
1968+
cd examples/audit && go run main.go
19691969
```
19701970

1971-
### `_example/reporting/` — Financial Quarter & Fiscal-Year Reporting
1971+
### `examples/reporting/` — Financial Quarter & Fiscal-Year Reporting
19721972

19731973
**Business problem:** A publicly-traded company needs precise SEC filing
19741974
windows, YTD periods, QoQ comparisons, and a July-1-start fiscal year
@@ -1991,10 +1991,10 @@ calendar.
19911991
| `New(t).Quarter()` | Quarter number label |
19921992

19931993
```bash
1994-
cd _example/reporting && go run main.go
1994+
cd examples/reporting && go run main.go
19951995
```
19961996

1997-
### `_example/scheduler/` — Business-Day-Aware Job Scheduler
1997+
### `examples/scheduler/` — Business-Day-Aware Job Scheduler
19981998

19991999
**Business problem:** A financial data platform schedules ETL jobs on daily,
20002000
monthly, and quarterly boundaries, ensuring jobs fire only on business days and
@@ -2017,7 +2017,7 @@ are not duplicated within a configurable time window.
20172017
| `New(t).TimeAgo()` / `TimeUntil()` | Last-ran / next-run display |
20182018

20192019
```bash
2020-
cd _example/scheduler && go run main.go
2020+
cd examples/scheduler && go run main.go
20212021
```
20222022

20232023
---

examples/audit/main.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//
1313
// Run with:
1414
//
15-
// cd _example/audit && go run main.go
15+
// cd examples/audit && go run main.go
1616
package main
1717

1818
import (
@@ -35,19 +35,19 @@ const (
3535

3636
// AuditEvent is a single immutable audit record.
3737
type AuditEvent struct {
38-
ID string
39-
OccurredAt time.Time // stored in UTC, nanosecond precision
40-
ActorID string
41-
Action string
42-
Resource string
43-
Severity Severity
44-
Resolved bool
45-
ResolvedAt time.Time // zero value if unresolved
38+
ID string
39+
OccurredAt time.Time // stored in UTC, nanosecond precision
40+
ActorID string
41+
Action string
42+
Resource string
43+
Severity Severity
44+
Resolved bool
45+
ResolvedAt time.Time // zero value if unresolved
4646
}
4747

4848
// HourBucket groups audit events that occurred within the same UTC hour.
4949
type HourBucket struct {
50-
Hour time.Time // beginning of the hour (UTC)
50+
Hour time.Time // beginning of the hour (UTC)
5151
Events []AuditEvent
5252
}
5353

@@ -59,6 +59,7 @@ type HourBucket struct {
5959
// - Using time.Add(72 * time.Hour) is equivalent here, but AddHour reads as
6060
// intent-revealing code in an audit context where "hours" is the business
6161
// unit mandated by law.
62+
//
6263
// ─────────────────────────────────────────────────────────────────────────────
6364
func gdprBreachDeadline(detectedAt time.Time) time.Time {
6465
return timefy.AddHour(detectedAt, 72)
@@ -87,6 +88,7 @@ func isGDPRCompliant(detectedAt, reportedAt time.Time) bool {
8788
// - SLAs in enterprise support contracts only count working hours.
8889
// A ticket created at 17:00 Friday with a 4-hour SLA should expire at
8990
// 13:00 Monday, not 21:00 Friday (which would already be closed).
91+
//
9092
// ─────────────────────────────────────────────────────────────────────────────
9193
func slaDeadline(createdAt time.Time, businessHours int) time.Time {
9294
cursor := createdAt

examples/billing/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// Run with:
99
//
10-
// cd _example/billing && go run main.go
10+
// cd examples/billing && go run main.go
1111
package main
1212

1313
import (

examples/global_team/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//
1414
// Run with:
1515
//
16-
// cd _example/global_team && go run main.go
16+
// cd examples/global_team && go run main.go
1717
package main
1818

1919
import (

examples/reporting/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//
1212
// Run with:
1313
//
14-
// cd _example/reporting && go run main.go
14+
// cd examples/reporting && go run main.go
1515
package main
1616

1717
import (

examples/scheduler/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//
1515
// Run with:
1616
//
17-
// cd _example/scheduler && go run main.go
17+
// cd examples/scheduler && go run main.go
1818
package main
1919

2020
import (

0 commit comments

Comments
 (0)