MCPcopy Create free account
hub / github.com/bendrucker/postgres-interval / toISOString

Function toISOString

index.js:115–157  ·  view source on GitHub ↗
({ short })

Source from the content-addressed store, hash-verified

113}
114
115function toISOString ({ short }) {
116 let datePart = ''
117
118 if (!short || this.years) {
119 datePart += this.years + propertiesISOEquivalent.years
120 }
121
122 if (!short || this.months) {
123 datePart += this.months + propertiesISOEquivalent.months
124 }
125
126 if (!short || this.days) {
127 datePart += this.days + propertiesISOEquivalent.days
128 }
129
130 let timePart = ''
131
132 if (!short || this.hours) {
133 timePart += this.hours + propertiesISOEquivalent.hours
134 }
135
136 if (!short || this.minutes) {
137 timePart += this.minutes + propertiesISOEquivalent.minutes
138 }
139
140 if (!short || (this.seconds || this.milliseconds)) {
141 if (this.milliseconds) {
142 timePart += (Math.trunc((this.seconds + this.milliseconds / 1000) * 1000000) / 1000000) + propertiesISOEquivalent.seconds
143 } else {
144 timePart += this.seconds + propertiesISOEquivalent.seconds
145 }
146 }
147
148 if (!timePart && !datePart) {
149 return 'PT0S'
150 }
151
152 if (!timePart) {
153 return `P${datePart}`
154 }
155
156 return `P${datePart}T${timePart}`
157}
158
159const position = { value: 0 }
160

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…