Ejemplo n.º 1
0
static PyObject *bits__localtime(PyObject *self, PyObject *args)
{
    struct grub_datetime datetime;
    int weekday;
    PyObject *seconds = NULL;

    if (!PyArg_ParseTuple(args, "|O", &seconds))
        return NULL;

    if (!seconds || seconds == Py_None)
        grub_get_datetime(&datetime);
    else {
        long s = PyFloat_AsDouble(seconds);
        if (PyErr_Occurred())
            return NULL;
        grub_unixtime2datetime(s, &datetime);
    }

    // Get weekday and convert from Sunday=0 to Monday=0
    weekday = (grub_get_weekday(&datetime) + 6) % 7;

    return Py_BuildValue("HBBBBBiii", datetime.year, datetime.month,
                                      datetime.day, datetime.hour,
                                      datetime.minute, datetime.second,
                                      weekday, -1, -1);
}
Ejemplo n.º 2
0
static PyObject *bits__localtime(PyObject *self, PyObject *args)
{
    struct grub_datetime datetime;
    int weekday;
    long int seconds = -1L;

    if (!PyArg_ParseTuple(args, "|I", &seconds))
        return NULL;

    if (seconds == -1L)
        grub_get_datetime(&datetime);
    else
        grub_unixtime2datetime(seconds, &datetime);

    // Get weekday and convert from Sunday=0 to Monday=0
    weekday = (grub_get_weekday(&datetime) + 6) % 7;

    return Py_BuildValue("HBBBBBiii", datetime.year, datetime.month,
                                      datetime.day, datetime.hour,
                                      datetime.minute, datetime.second,
                                      weekday, -1, -1);
}
Ejemplo n.º 3
0
const char *
grub_get_weekday_name (struct grub_datetime *datetime)
{
  return _ (grub_weekday_names[grub_get_weekday (datetime)]);
}
Ejemplo n.º 4
0
char *
grub_get_weekday_name (struct grub_datetime *datetime)
{
  return grub_weekday_names[grub_get_weekday (datetime)];
}