Skip to content

Commit

Permalink
Fix some bugs in GCN Circulars subject placeholder (#796)
Browse files Browse the repository at this point in the history
- Fix off-by-one error in month
- Fix day-of-month (was set to day-of-week)
- Move long expressions out of template string to improve code
  readability
  • Loading branch information
lpsinger authored Apr 13, 2023
1 parent d1b8c25 commit ac71839
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app/routes/circulars/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ export async function loader({ request }: DataFunctionArgs) {

function useSubjectPlaceholder() {
const date = new Date()
return `GRB ${(date.getUTCFullYear() % 1000)
.toString()
.padStart(2, '0')}${date.getUTCMonth().toString().padStart(2, '0')}${date
.getUTCDay()
.toString()
.padStart(2, '0')}A: observations of a gamma-ray burst`
const YY = (date.getUTCFullYear() % 1000).toString().padStart(2, '0')
const MM = (date.getUTCMonth() + 1).toString().padStart(2, '0')
const DD = date.getUTCDate().toString().padStart(2, '0')
return `GRB ${YY}${MM}${DD}A: observations of a gamma-ray burst`
}

function useBodyPlaceholder() {
Expand Down

0 comments on commit ac71839

Please sign in to comment.