ssb-konjunk 0.1.16__py3-none-any.whl → 0.1.17__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ssb_konjunk/prompts.py CHANGED
@@ -271,6 +271,59 @@ def validate_day(day: int | str) -> str:
271
271
  day = "0" + str(int(day))
272
272
  return str(day)
273
273
 
274
+
275
+ def quarter_for_month(month: str | int) -> int:
276
+ """Find corresponding quarter for a month.
277
+
278
+ Args:
279
+ month: Month to find corresponding quarter for.
280
+
281
+ Returns:
282
+ int: The corresponding quarter.
283
+
284
+ Raises:
285
+ ValueError: If invalid month
286
+ """
287
+ month = int(month)
288
+
289
+ if month < 1 or month > 12:
290
+ raise ValueError(f"Invalid month: {month}")
291
+
292
+ if month < 4:
293
+ return 1
294
+ elif month < 7:
295
+ return 2
296
+ elif month < 10:
297
+ return 3
298
+ else:
299
+ return 4
300
+
301
+
302
+ def months_in_quarter(quarter: int | str) -> list[int]:
303
+ """Return the three months in the quarter.
304
+
305
+ Args:
306
+ quarter: the relevant quarter.
307
+
308
+ Returns:
309
+ list: a list with the months in the quarter.
310
+
311
+ Raises:
312
+ ValueError: If invalid quarter.
313
+ """
314
+ quarter = int(quarter)
315
+
316
+ if quarter < 1 or quarter > 4:
317
+ raise ValueError(f"Invalid quarter: {quarter}")
318
+
319
+ if quarter == 1:
320
+ return [1, 2, 3]
321
+ elif quarter == 2:
322
+ return [4, 5, 6]
323
+ elif quarter == 3:
324
+ return [7, 8, 9]
325
+ else:
326
+ return [10, 11, 12]
274
327
 
275
328
  def set_publishing_date() -> str:
276
329
  """Set the date for publication of tables.
@@ -355,4 +408,4 @@ def get_previous_month(year: str | int, month: str | int) -> list[int]:
355
408
  prev_month = 12
356
409
  prev_year = int(year) - 1
357
410
 
358
- return [prev_year, prev_month]
411
+ return [prev_year, prev_month]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ssb-konjunk
3
- Version: 0.1.16
3
+ Version: 0.1.17
4
4
  Summary: SSB Konjunk
5
5
  Home-page: https://github.com/statisticsnorway/ssb-konjunk
6
6
  License: MIT
@@ -3,15 +3,15 @@ ssb_konjunk/__main__.py,sha256=bqGEjbMKlKza1kQeyZ5NcjV5p5vsGpoQ81YhO8cGPvk,213
3
3
  ssb_konjunk/_functions.py,sha256=Dp39rEMqR0M43o4mCujoRzlSyT_rHYcK6VHHc9wSY8E,470
4
4
  ssb_konjunk/data_formating.py,sha256=7GcDS_wsHWzCNJg4wpj-zFRWYX0c1KAB4FcbxZ9Ez4A,627
5
5
  ssb_konjunk/fame.py,sha256=6Yw0D1kY20yOu49DHgwfSIAmiHVCERuMeIANg1lYu64,1619
6
- ssb_konjunk/prompts.py,sha256=DsXmM4JWY3-WGb6ebj819zhaJ01JT8IL1226yadk724,9164
6
+ ssb_konjunk/prompts.py,sha256=htj9zQxr2vgAr3pkke9lGiNM3pkbOQ1W7FA4JJ0o6Tk,10269
7
7
  ssb_konjunk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  ssb_konjunk/rounding.py,sha256=nbxYMvvFzoJOxwJBCA80OyaZGhhOHCxbndeYB271Uzk,1269
9
9
  ssb_konjunk/saving.py,sha256=3lwYNnwh5Z-wbWJfiqaXwvsvya3zwBrEEE_3XejjtNI,14567
10
10
  ssb_konjunk/statbank_format.py,sha256=cVXrq2qSuMk-FAiMdbIS8Cc8YgZUyTCKnsMdknMbfkM,1469
11
11
  ssb_konjunk/timestamp.py,sha256=XPB5JhZQdDgUPYYNVAFiMZGe8dYL8seb_k98G9CNtjY,9960
12
12
  ssb_konjunk/xml_handling.py,sha256=kvAZ699iOSxHCi2ksEGroFk60-ufsRW7b_m3j47A2gY,1726
13
- ssb_konjunk-0.1.16.dist-info/LICENSE,sha256=np3IfD5m0ZUofn_kVzDZqliozuiO6wrktw3LRPjyEiI,1073
14
- ssb_konjunk-0.1.16.dist-info/METADATA,sha256=eRvDsatdB6QKPv6Q3g7DaAniJfgZH8KjCR9AcB9MaN8,3966
15
- ssb_konjunk-0.1.16.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
16
- ssb_konjunk-0.1.16.dist-info/entry_points.txt,sha256=qU7y58sZiFKYonuEJTbV0MhhbAJtposy46crLp4TjAM,57
17
- ssb_konjunk-0.1.16.dist-info/RECORD,,
13
+ ssb_konjunk-0.1.17.dist-info/LICENSE,sha256=np3IfD5m0ZUofn_kVzDZqliozuiO6wrktw3LRPjyEiI,1073
14
+ ssb_konjunk-0.1.17.dist-info/METADATA,sha256=xSofBjnYyeK75w_2c1k4L427LjGvmAqp1BBdtzOu-UI,3966
15
+ ssb_konjunk-0.1.17.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
16
+ ssb_konjunk-0.1.17.dist-info/entry_points.txt,sha256=qU7y58sZiFKYonuEJTbV0MhhbAJtposy46crLp4TjAM,57
17
+ ssb_konjunk-0.1.17.dist-info/RECORD,,