Data update
This commit is contained in:
parent
ed705008a8
commit
0df55f9f24
2196 changed files with 32999 additions and 3075 deletions
34
Task/Date-manipulation/MiniScript/date-manipulation.mini
Normal file
34
Task/Date-manipulation/MiniScript/date-manipulation.mini
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import "dateTime"
|
||||
import "stringUtil"
|
||||
|
||||
months = [
|
||||
"January", "February", "March", "April", "May", "June",
|
||||
"July", "August", "September", "October", "November", "December",
|
||||
]
|
||||
|
||||
date = "March 7 2009 7:30pm EST"
|
||||
print "Original date/time : " + date
|
||||
|
||||
// change the date to standard format
|
||||
items = date.split
|
||||
month = months.indexOf(items[0]) + 1
|
||||
day = items[1]
|
||||
year = items[2]
|
||||
time = items[3]
|
||||
hour = time.split(":")[0].val
|
||||
minute = time.split(":")[1][0:2]
|
||||
pm = time.endsWith("pm")
|
||||
if pm then hour = hour + 12
|
||||
time = hour + ":" + minute
|
||||
zone = items[4]
|
||||
date = year + "-" + month + "-" + day + " " + time
|
||||
|
||||
// add 12 hours and display in original format
|
||||
dval = dateTime.val(date) + 12*60*60
|
||||
dfmt = "MMMM d yyyy h:mmtt"
|
||||
date2 = dateTime.str(dval, dfmt) + " " + zone
|
||||
print "12 hours later : " + date2
|
||||
|
||||
// change from EST to MST (2 hours earlier)
|
||||
date3 = dateTime.str(dval - 2*60*60, dfmt) + " MST"
|
||||
print "Adjusted to MST : " + date3
|
||||
Loading…
Add table
Add a link
Reference in a new issue