# File: easyrtc.py
# Version: 1
# Description: Wrapper that makes using the clock simple
# License: MIT
# Authors: Renze Nicolai <renze@rnplus.nl>

import machine, time

# Functions
def string(date=False, time=True):
    [year, month, mday, wday, hour, min, sec, usec] = machine.RTC().datetime()
    monthstr = str(month)
    if (month<10):
      monthstr = "0"+monthstr
    daystr = str(mday)
    if (mday<10):
      daystr = "0"+daystr
    hourstr = str(hour)
    if (hour<10):
      hourstr = "0"+hourstr
    minstr = str(min)
    if (min<10):
      minstr = "0"+minstr 
    output = ""
    if date:
        output += daystr+"-"+monthstr+"-"+str(year)
        if time:
            output += " "
    if time:
        output += hourstr+":"+minstr
    return output

def configure():
    import easywifi
    import easydraw
    import ntp
    if not easywifi.status():
        if not easywifi.enable():
            return False
    easydraw.msg("Configuring clock...")
    ntp.set_NTP_time()
    easydraw.msg("Done")
    return True

@@ -186,16 +186,22 @@
  string(
+print_
 date=Fal
@@ -204,16 +204,22 @@
 =False, 
+print_
 time=Tru
@@ -219,19 +219,59 @@
 ime=True
-):%0A
+, timestamp = -1):%0A    if timestamp%3C0:%0A    
     %5Byea
@@ -301,16 +301,19 @@
 our, min
+ute
 , sec, u
@@ -340,24 +340,124 @@
 .datetime()%0A
+    else:%0A        %5Byear, month, mday, hour, minute, second, wday, yday%5D = time.localtime(timestamp)%0A
     monthstr
@@ -676,16 +676,19 @@
  str(min
+ute
 )%0A    if
@@ -692,16 +692,19 @@
  if (min
+ute
 %3C10):%0A  
@@ -751,16 +751,22 @@
 %0A    if 
+print_
 date:%0A  
@@ -858,23 +858,29 @@
  += %22 %22%0A
-
     if 
+print_
 time:%0A  

Add optional timestamp argument to easyrtc.string()