-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathDateType.hh
38 lines (32 loc) · 959 Bytes
/
DateType.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @file DateType.hh
* @author Caleb Aikens (caleb@distributive.network) and Philippe Laporte (philippe@distributive.network)
* @brief Struct for representing python dates
* @date 2022-12-21
*
* @copyright Copyright (c) 2022,2024 Distributive Corp.
*
*/
#ifndef PythonMonkey_DateType_
#define PythonMonkey_DateType_
#include <jsapi.h>
#include <js/Date.h>
#include <Python.h>
/**
* @brief This struct represents the 'datetime' type in Python from the datetime module, which is represented as a 'Date' object in JS
*/
struct DateType {
public:
/**
* @brief Convert a JS Date object to Python datetime
*/
static PyObject *getPyObject(JSContext *cx, JS::HandleObject dateObj);
/**
* @brief Convert a Python datetime object to JS Date
*
* @param cx - javascript context pointer
* @param pyObject - the python datetime object to be converted
*/
static JSObject *toJsDate(JSContext *cx, PyObject *pyObject);
};
#endif