forked from SistemasAgiles/pyafipws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
php.py
37 lines (31 loc) · 1.25 KB
/
php.py
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
#!/usr/bin/python
# -*- coding: latin-1 -*-
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
"Módulo con funciones y objetos para compatibilidad con PHP"
__author__ = "Mariano Reingart ([email protected])"
__copyright__ = "Copyright (C) 2008 Mariano Reingart"
__license__ = "LGPL 3.0"
__version__ = "1.0"
import datetime, sys, time
import xml.dom.minidom
import httplib2
from soap import SoapFault, SoapClient, parse_proxy, SimpleXMLElement
def date(fmt=None,timestamp=None):
"Manejo de fechas (simil PHP)"
if fmt=='U': # return timestamp
t = datetime.datetime.now()
return int(time.mktime(t.timetuple()))
if fmt=='c': # return isoformat
d = datetime.datetime.fromtimestamp(timestamp)
return d.isoformat()
if fmt=='Ymd':
d = datetime.datetime.now()
return d.strftime("%Y%m%d")