@@ -6,14 +6,29 @@ module Data.Intl.DateTimeFormat.Types
66 , FormatParts(..)
77 , readFormatParts
88 , ResolvedOptions(..)
9+ , WeekdayYearMonthDayHourMinuteSecond(..)
10+ , WeekdayYearMonthDay(..)
11+ , YearMonthDay(..)
12+ , YearMonth(..)
13+ , MonthDay(..)
14+ , HourMinuteSecond(..)
15+ , HourMinute(..)
16+ , Undefined
17+ , undefined
918 ) where
1019
1120import Data.Foreign (F, Foreign, ForeignError(..), fail, readString)
1221import Data.Foreign.Index ((!))
22+import Data.Generic (class Generic)
23+import Data.Intl.DateTimeFormat.Class (class FormatComponent)
24+import Data.Intl.DateTimeFormat.Generic (genericFormatComponent)
1325import Data.Maybe (Maybe)
1426import Data.Newtype (class Newtype)
1527import Prelude (class Show, bind, pure, ($), (<>), (>>=))
1628
29+foreign import data Undefined :: Type
30+foreign import undefined :: Undefined
31+
1732data StringRep = Narrow | Short | Long
1833
1934instance showStringRep :: Show StringRep where
@@ -86,3 +101,82 @@ newtype ResolvedOptions = ResolvedOptions
86101 }
87102
88103derive instance newtypeResolvedOptions :: Newtype ResolvedOptions _
104+
105+newtype WeekdayYearMonthDayHourMinuteSecond = WeekdayYearMonthDayHourMinuteSecond
106+ { weekday :: StringRep
107+ , year :: NumericRep
108+ , month :: MonthRep
109+ , day :: NumericRep
110+ , hour :: NumericRep
111+ , minute :: NumericRep
112+ , second :: NumericRep
113+ }
114+
115+derive instance genericWeekdayYearMonthDayHourMinuteSecond :: Generic WeekdayYearMonthDayHourMinuteSecond _
116+
117+instance formatComponentWeekdayYearMonthDayHourMinuteSecond :: FormatComponent WeekdayYearMonthDayHourMinuteSecond where
118+ formatComponent = genericFormatComponent
119+
120+newtype WeekdayYearMonthDay = WeekdayYearMonthDay
121+ { weekday :: StringRep
122+ , year :: NumericRep
123+ , month :: MonthRep
124+ , day :: NumericRep
125+ }
126+
127+derive instance genericWeekdayYearMonthDay :: Generic WeekdayYearMonthDay _
128+
129+instance formatComponentWeekdayYearMonthDay :: FormatComponent WeekdayYearMonthDay where
130+ formatComponent = genericFormatComponent
131+
132+newtype YearMonthDay = YearMonthDay
133+ { year :: NumericRep
134+ , month :: MonthRep
135+ , day :: NumericRep
136+ }
137+
138+derive instance genericYearMonthDay :: Generic YearMonthDay _
139+
140+instance formatComponentYearMonthDay :: FormatComponent YearMonthDay where
141+ formatComponent = genericFormatComponent
142+
143+newtype YearMonth = YearMonth
144+ { year :: NumericRep
145+ , month :: MonthRep
146+ }
147+
148+derive instance genericYearMonth :: Generic YearMonth _
149+
150+instance formatComponentYearMonth :: FormatComponent YearMonth where
151+ formatComponent = genericFormatComponent
152+
153+newtype MonthDay = MonthDay
154+ { month :: MonthRep
155+ , day :: NumericRep
156+ }
157+
158+derive instance genericMonthDay :: Generic MonthDay _
159+
160+instance formatComponentMonthDay :: FormatComponent MonthDay where
161+ formatComponent = genericFormatComponent
162+
163+newtype HourMinuteSecond = HourMinuteSecond
164+ { hour :: NumericRep
165+ , minute :: NumericRep
166+ , second :: NumericRep
167+ }
168+
169+derive instance genericHourMinuteSecond :: Generic HourMinuteSecond _
170+
171+instance formatComponentHourMinuteSecond :: FormatComponent HourMinuteSecond where
172+ formatComponent = genericFormatComponent
173+
174+newtype HourMinute = HourMinute
175+ { hour :: NumericRep
176+ , minute :: NumericRep
177+ }
178+
179+derive instance genericHourMinute :: Generic HourMinute _
180+
181+instance formatComponentHourMinute :: FormatComponent HourMinute where
182+ formatComponent = genericFormatComponent